当我向右滚动 300 像素时如何获得回调?
<div id="container">
<div class="scrollable">
this will be 6000px wide
</div>
</div>
css
#container {width: 900px; overflow: hidden;}
.scrollable {width: 6000px; overflow-x: scroll;}
js(随意重写,我只是尝试这个作为例子)
$('#container').scroll(function (evt) {
var target = $(evt.currentTarget);
horizontal_scroll = target.scrollLeft();
if (previous_scroll < horizontal_scroll && horizontal_scroll % 100 == 0) {
previous_scroll = horizontal_scroll;
alert("You've scrolled 300px to the right");
}
});