1/** 2 * jQuery Unveil 3 * A very lightweight jQuery plugin to lazy load images 4 * http://luis-almeida.github.com/unveil 5 * 6 * Licensed under the MIT license. 7 * Copyright 2013 LuÃs Almeida 8 * https://github.com/luis-almeida 9 */ 10 11 12(function($) { 13 14 $.fn.unveil = function(threshold, callback, elem) { 15 16 var $w = elem ? $(elem) : $(window); 17 var th = threshold || 0; 18 var retina = window.devicePixelRatio > 1; 19 var attrib = retina ? "data-src-retina" : "data-src"; 20 var images = this; 21 var loaded; 22 23 this.one("unveil", function() { 24 var source = this.getAttribute(attrib); 25 source = source || this.getAttribute("data-src"); 26 if (source) { 27 this.setAttribute("src", source); 28 if ( typeof callback === "function") 29 callback.call(this); 30 } 31 }); 32 33 function unveil() { 34 var woffset = ($w.offset() ? $w.offset().top : 0) - $(document).scrollTop(); 35 var inview = images.filter(function() { 36 var $e = $(this); 37 if ($e.data('pauseUnveil')) return; 38 if ($e.css('display') == 'none') {//is(":hidden")) 39 return; 40 } 41 42 var wt = woffset + $w.scrollTop(); 43 var wb = wt + $w.height(); 44 var et = $e.offset().top - $(document).scrollTop(); 45 var eb = et + $e.height(); 46 47 return /*eb >= wt - th && */et <= wb + th; 48 }); 49 50 loaded = inview.trigger("unveil"); 51 images = images.not(loaded); 52 } 53 54 55 $w.on("scroll.unveil resize.unveil lookup.unveil", unveil); 56 57 unveil(); 58 59 return this; 60 61 }; 62 63})(window.jQuery || window.Zepto); 64
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.