admin管理员组文章数量:1390456
Skrollr is an awesome plugin, plenty of options, but I can't really understand if there's some method for passing a function when the scroll position is after the last keyframe. For example, take a look at this fiddle.
When you scroll the top 100 pixels, the scrollable-between
class changes in scrollable-after
. In a similar way I'd like to pass a function (ex: when the scroll position is after the last keyframe do stuff).
How would you achieve that?
Skrollr is an awesome plugin, plenty of options, but I can't really understand if there's some method for passing a function when the scroll position is after the last keyframe. For example, take a look at this fiddle.
When you scroll the top 100 pixels, the scrollable-between
class changes in scrollable-after
. In a similar way I'd like to pass a function (ex: when the scroll position is after the last keyframe do stuff).
How would you achieve that?
Share Improve this question asked Dec 3, 2013 at 15:15 user1861373user1861373 851 silver badge9 bronze badges1 Answer
Reset to default 6You'll want to use the render
option. Something like the following:
var box = $('#box'),
boxDone = false;
skrollr.init({
forceHeight: false,
smoothScrolling: false,
render: function() {
if ( box.hasClass('skrollable-after') ) {
if ( ! boxDone ) {
boxDone = true;
// do stuff
}
} else if ( boxDone ) {
boxDone = false;
}
}
});
You don't necessarily have to have the boxDone
variable, but it keeps it from running multiple times when that happens. You could also make it only happen once by not reseting that variable.
FIDDLE
I should probably also mention that you'll want make sure that whatever you do in there should run really fast or you run the risk of slowing down how smoothly everything moves. You might be able to get around that by using setTimeout
, but I haven't done any testing with that.
本文标签: javascriptSkrollr pass a function when the scroll position is after the last keyframeStack Overflow
版权声明:本文标题:javascript - Skrollr: pass a function when the scroll position is after the last keyframe - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744707050a2620902.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论