Jump to content
Search Community

Ben Stanley

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by Ben Stanley

  1. Never mind. I was doing some reading up, and people suggest that using prototypes isn't a great idea. I just switched it to a function instead. Works fine now.
  2. Hi, I wrote a custom Javascript function to preload images on my site (completely unrelated to GSAP). I used the Object prototype method. Object.prototype.preloadImages = function(callback) { /* ... */ }; This is how it looks. The code inside is just plain JS. But whenever I add it to my project, GSAP throws an error: GSAP encountered missing dependency: com.greensock.preloadImages. Then it logs: Uncaught TypeError: o.parse is not a function (logs this error over and over) Seems like GSAP is seeing the new function and trying to do something related to it. Any suggestions on how to fix it? I could just switch it from Object.prototype to a regular function; but I prefer having it this way. It's a re-usable plugin that I include in lots of projects, so I don't really want to change it just for this.
  3. Ah, thanks very much. element.animation = tl; I didn't know you could set an animation to an element like this. Perfect. Exactly what I needed. Cheers, Ben
  4. I have this Timeline set up, var tl = new TimelineLite(); tl.to($('.button'), 0.25, {backgroundPosition: 'left top', ease: Expo.easeOut}, "background") .to($('.button-inner'), 0.25, {backgroundPosition: 'left top', ease: Expo.easeOut}, "background") .to($('.button-text'), 0.5, {marginTop: 70, opacity: 1, ease: Back.easeOut}, "text-=0.125") .to($('.button-readmore'), 0.25, {scale: 1, opacity: 1, ease: Back.easeOut}, "text"); And I want to use this same Timeline animation for multiple 'button' classes. I want it to play on hover, then reverse on hover off. Am I able to call the timeline and just give the object to use? I tried putting it in a function, and then calling it with the object as a parameter, but I'm having trouble since that method doesn't work for reversing the animation on hover-off. I am thinking I will have to create an instance of this Timeline animation when I hover on, then remove it once it's finished reversing, but I'm not too sure of how to approach it. Cheers, Ben
×
×
  • Create New...