ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[nathco/jQuery.loadScroll: Extension for loading images while scrolling (github.com)](https://github.com/nathco/jQuery.loadScroll) ``` // Plugin: jQuery.loadScroll // Source: github.com/nathco/jQuery.loadScroll // Author: Nathan Rutzky // Update: 1.0.1 (function($) { $.fn.loadScroll = function(duration) { var $window = $(window), images = this, inview, loaded; images.one('loadScroll', function() { if (this.getAttribute('data-src')) { this.setAttribute('src', this.getAttribute('data-src')); this.removeAttribute('data-src'); if (duration) { $(this).hide() .fadeIn(duration) .add('img') .removeAttr('style'); } else return false; } }); $window.scroll(function() { inview = images.filter(function() { var a = $window.scrollTop(), b = $window.height(), c = $(this).offset().top, d = $(this).height(); return c + d >= a && c <= a + b; }); loaded = inview.trigger('loadScroll'); images = images.not(loaded); }); }; })(jQuery); ```