我使用的是smoothStates默认设置,我想知道是否可以将类添加到主包装中,以便我可以更改网站的背景颜色?我不想在main下添加另一个div作为其额外的标记。smoothState.js:将类添加到#main包装
目前我只能添加页面索引,然后其他页面不会改变,因为smoothState不会再次加载页面。
编辑:所以我想补充一类的每一页,如:page-index
,page-about
等。
我有一个div像这样:
<div id="main">
// stuff here
</div>
当你点击/新闻:
<div id="main" class="page-news">
// stuff here
</div>
我的功能:
$(function(){
'use strict';
var options = {
prefetch: true,
cacheLength: 2,
onStart: {
duration: 250, // Duration of our animation
render: function ($container) {
// Add your CSS animation reversing class
$container.addClass('is-exiting');
// Restart your animation
smoothState.restartCSSAnimations();
}
},
onReady: {
duration: 0,
render: function ($container, $newContent) {
// Remove your CSS animation reversing class
$container.removeClass('is-exiting');
// Inject the new content
$container.html($newContent);
}
}
},
smoothState = $('#main').smoothState(options).data('smoothState');
});
什么时候你想添加类?之前,之前,在动画中间? – jonhue
嗨,从人们访问主页开始。 –
你是什么意思?所有动画完成后? – jonhue