答案 0 :(得分:1)
您应该使用onLeave
回调,或者如果您愿意,可以使用afterLoad
回调。
这样,当您从一张幻灯片移动到另一张幻灯片时,您可以发射一些东西。
<强> jQuery的:强>
$.fn.fullpage({
afterLoad: function (anchor, index) {
$('#cog').toggleClass('active');
}
});
<强> CSS 强>
#cog {
background: white;
border-radius: 10px;
width: 40px;
height: 40px;
position: fixed;
top: 20px;
left: 20px;
}
#cog.active {
transform: rotate(180deg);
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-webkit-transition: all 0.3s ease-out;
-moz-transition: all 0.3s ease-out;
-o-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
}
答案 1 :(得分:0)
那里有很多答案,你应该google:
示例:
var $cog = $('#cog'),
$body = $(document.body),
bodyHeight = $body.height();
$(window).scroll(function () {
$cog.css({
'transform': 'rotate(' + ($body.scrollTop() / bodyHeight * 360) + 'deg)'
});
});
$(function() {
var rotation = 0,
scrollLoc = $(document).scrollTop();
$(window).scroll(function() {
var newLoc = $(document).scrollTop();
var diff = scrollLoc - newLoc;
rotation += diff, scrollLoc = newLoc;
var rotationStr = "rotate(" + rotation + "deg)";
$(".gear").css({
"-webkit-transform": rotationStr,
"-moz-transform": rotationStr,
"transform": rotationStr
});
});
})