6

我有一个带有许多标签的 html 文件。

我想在滚动事件上加载图像,并卸载不可见的图像。就像在 Aamzaon 查看器中一样,当您向上/向下滚动时,帧中的当前图像是延迟加载的。

我看到很多 LazyLoad 工具,但没有一个具有卸载功能。

4

1 回答 1

2

Use this plugins jquery: https://github.com/morr/jquery.appear And use event: appear to display images and disappear to unload images:

$('someselector').on('appear', function(event, $all_appeared_elements) {
  // this element is now inside browser viewport
});
$('someselector').on('disappear', function(event, $all_disappeared_elements) {
  // this element is now outside browser viewport
});
于 2013-10-03T08:50:52.807 回答