简体   繁体   English

jQuery添加缓动会中断随后的动画。 语法错误?

[英]jQuery adding easing breaks animations that come after. Syntax Error?

I'm adding animations to a website, and having a bit of a hard time adding easing. 我正在将动画添加到网站上,并且在添加宽松效果方面有些困难。 I can get the entire animation sequence to run correctly, but when I try to define the easing, the animations break on all the animations that come after the first element where I define easing. 我可以使整个动画序列正确运行,但是当我尝试定义缓动时,动画会在定义缓动的第一个元素之后的所有动画上中断。

The basic animation sequence is the bottom half the page fades in and flies up to meet the top half. 基本的动画序列是页面的下半部分淡入并向上飞以满足上半部分。 Then three buttons fade in and fly up sequentially to their designated locations. 然后,三个按钮淡入并顺序向上飞到其指定位置。 It looks alright, but it would look a lot better with easOutBounce . 看起来不错,但是使用easOutBounce看起来会更好。

I have now been wrestling with this for too long, trying to figure out why adding the easing breaks my code. 我现在已经为此花了很长时间,试图弄清楚为什么添加缓动会破坏我的代码。 I'm guessing my syntax is incorrect. 我猜我的语法不正确。

THIS code works on all elements: 此代码适用于所有元素:

jQuery( '.front-page-content-wrap' ).animate( {marginTop: 0, opacity: 1}, 600, function(){
    jQuery( "#box-button-1" ).animate( { bottom: 78, opacity: 1 }, function(){
       jQuery( "#box-button-2" ).animate( { bottom: 78, opacity: 1 }, function(){
         jQuery( "#box-button-3" ).animate( { bottom: 78, opacity: 1 } );
       } ); 
    } );  
});

BUT this code doesn't. 但是此代码没有。 When I run this code, it does add the easing and it still works on the .front-page-content-wrap , and the #box-button-1 , but then it stops. 当我运行此代码时,它确实添加了缓动效果,并且仍然适用于.front-page-content-wrap#box-button-1 ,但是随后停止了。

jQuery( '.front-page-content-wrap' ).animate( {marginTop: 0, opacity: 1}, 600, function(){
    jQuery( "#box-button-1" ).animate( { bottom: 78, opacity: 1 }, { easing: 'easeOutBounce' }, function(){
       jQuery( "#box-button-2" ).animate( { bottom: 78, opacity: 1 }, { easing: 'easeOutBounce' }, function(){
         jQuery( "#box-button-3" ).animate( { bottom: 78, opacity: 1 }, { easing: 'easeOutBounce' } );
       } ); 
    } );  
});

Any ideas? 有任何想法吗?

PS, I'm using jQuery as the variable identifier instead of $, because I'm working in wordpress which runs in no-conflict mode. PS,我使用jQuery作为变量标识符而不是$,因为我正在以无冲突模式运行的wordpress中工作。

Try this syntax: .animate( properties, options ) 尝试使用以下语法: .animate( properties, options )

jQuery( '.front-page-content-wrap' ).animate( {marginTop: 0, opacity: 1}, 600, function(){
    jQuery( "#box-button-1" ).animate( { bottom: 78, opacity: 1 }, { easing: 'easeOutBounce', complete: function(){
       jQuery( "#box-button-2" ).animate( { bottom: 78, opacity: 1 }, { easing: 'easeOutBounce', complete: function(){
         jQuery( "#box-button-3" ).animate( { bottom: 78, opacity: 1 }, { easing: 'easeOutBounce' } );
       }}); 
    }});  
});

http://jsfiddle.net/mblase75/42BjC/ http://jsfiddle.net/mblase75/42BjC/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM