0
當我滾動到右側300px時,如何獲得回調?單向滾動時的回調函數
<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");
}
});