我只是想了解一个必须使用的jQuery脚本 现在我发现了以下片段:
$currPage.addClass( outClass ).on( animEndEventName, function() {
$currPage.off( animEndEventName );
endCurrPage = true;
if( endNextPage ) {
onEndAnimation( $currPage, $nextPage );
}
});
我已经知道的充实:
$currPage
:这是当前页面。它是<div class="page">
endCurrPage
:这是一个布尔值,标准为假
endNextPage
:与endCurrPage
我的问题是.on( animEndEventName,
部分。 animEndEventName
变量看起来像这样:
var animEndEventNames = {
'WebkitAnimation' : 'webkitAnimationEnd',
'OAnimation' : 'oAnimationEnd',
'msAnimation' : 'MSAnimationEnd',
'animation' : 'animationend'
},
animEndEventName = animEndEventNames[ Modernizr.prefixed( 'animation' ) ];
此代码由Modernizr.prefixed():http://modernizr.com/docs/#prefixed
提供 jQuery&#39; .on()
等待活动,animEndEventName
。那么这究竟是如何运作的?我不完全理解这一部分......
我希望你能帮助我。如果您需要更多代码,请说出来。但我认为这是相关部分。
编辑:
以下是codrops https://github.com/codrops/PageTransitions/blob/master/js/pagetransitions.js
答案 0 :(得分:1)
.on()
使用字符串和事件名称来添加处理程序。
无法知道或关心是否从变量或字符串文字中传递该字符串。