我使用jQuery工具插件作为图像滑块(image here),但由于大量的图像,我需要一次加载几个。因为它是javascript编码的,据我所知我不能知道滚动的位置。我想在最后一张图片或类似的东西出现时加载它们。我不知道我放在哪里,事件监听器也不知道。
下面是我的代码http://jsfiddle.net/PxGTJ/
请给我一点光!
发布于 2010-07-20 03:27:47
这可以通过以下方式实现:
//When the DOM is ready...
$(document).ready(function() {
//When the user scrolls...
$(window).scroll(function() {
var tolerance = 800,
scrollTop = $(window).scrollTop();
//If the the distance to the top is greater than the tolerance...
if(scrollTop > tolerance) {
//Do something. Ajax Call, Animations, whatever.
}
}) ;
});这应该能起到作用。
编辑:因为您没有使用原生滚动,所以我们必须对代码进行一些修复:
//When the DOM is ready...
$(document).ready(function() {
//When the user scrolls...
$("div.scrollable").find(".next").click(function() {
var tolerance = 800,
// The absolute value of the integer associated
// to the top css property
scrollTop = Math.abs(parseInt($("div.items").css("top")));
//If the the distance to the top is greater than the tolerance...
if(scrollTop > tolerance) {
//Do something. Ajax Call, Animations, whatever.
}
}) ;
});https://stackoverflow.com/questions/3283669
复制相似问题