Jump to content
Search Community

Animate In, Out per hover

anteksiler test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi there,

 

I have specific links, and hover, I would like to change the image on the right. However, since it's a long animation (I would like to fadeIn the image, and then have it zoom slowly), it's not working as I would like.

container.each(function() {
					var _this = $(this),
							images = _this.find('.portfolio-image'),
							links = _this.find('.type-portfolio');
					
					function animateOver(i, el) {
					  var tl = new TimelineMax();
					  

					  if (!images.eq(i).is(':visible')) {
					  	tl
					  		.to(images.filter(':visible'), 0.5, {autoAlpha: 0, scale: 1, display: 'none'}, 0) 
					  		.to(images.eq(i), 0.5, {autoAlpha: 1, display: 'block'}, 0);
					  }
					  
					  tl
					  	.add(TweenMax.to(images.eq(i), 5, {scale: 1.05}));
					  	
					  el.animation = tl;
					  return tl;
					}
					function animateOut(el){   
						el.animation.reverse();  
					
					};
					links.hoverIntent(function() {
							var i = $(this).index();
							animateOver(i, this);
					});
				});
Link to comment
Share on other sites

Hmm, i have some ideas but it's just too hard to figure out how to fix it without a live sample.

I think the problem may be that you are creating new animations on each mouseover.

 

In most cases I'd suggest creating a timeline animation for each element and then play/reverse as you mouseenter / mouseleave like: http://codepen.io/GreenSock/pen/WxgdRz

 

 

 

If you need more help with your specific demo can you reduce it as much as possible in a CodePen? http://greensock.com/forums/topic/9002-read-this-first-how-to-create-a-codepen-demo/

 

That will greatly help us help you.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...