mirror of
https://github.com/wordshub/free-font.git
synced 2026-08-01 06:47:39 +08:00
优化图片懒加载
This commit is contained in:
parent
4a1b23ed06
commit
0e374f842d
@ -111,6 +111,7 @@
|
||||
<script src="//cdn.jsdelivr.net/gh/wordshub/free-font/vendor/jquery-1.11.0.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/lazyload@2.0.0-rc.2/lazyload.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/gh/wordshub/free-font/vendor/isotope/isotope.pkgd.min.js"></script>
|
||||
<script src="//unpkg.com/imagesloaded@4/imagesloaded.pkgd.min.js"></script>
|
||||
<script src="//cdn.jsdelivr.net/gh/wordshub/free-font/js/custom.js"></script>
|
||||
<script src="js/data.js"></script>
|
||||
<script>
|
||||
@ -167,6 +168,7 @@
|
||||
var the_font_type = location.search.substring(1); //hei
|
||||
var $project_feed_wrapper = $(".project-feed-wrapper");
|
||||
var $container = $('.project-feed, .masonry-feed');
|
||||
|
||||
$container.imagesLoaded(function() {
|
||||
$container.isotope({
|
||||
filter: '*',
|
||||
|
||||
39
js/custom.js
39
js/custom.js
@ -1,42 +1,3 @@
|
||||
(function(c, q) {
|
||||
var m = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
|
||||
c.fn.imagesLoaded = function(f) {
|
||||
function n() {
|
||||
var b = c(j),
|
||||
a = c(h);
|
||||
d && (h.length ? d.reject(e, b, a) : d.resolve(e));
|
||||
c.isFunction(f) && f.call(g, e, b, a)
|
||||
}
|
||||
|
||||
function p(b) { k(b.target, "error" === b.type) }
|
||||
|
||||
function k(b, a) {
|
||||
b.src === m || -1 !== c.inArray(b, l) || (l.push(b), a ? h.push(b) : j.push(b), c.data(b, "imagesLoaded", { isBroken: a, src: b.src }), r && d.notifyWith(c(b), [a, e, c(j), c(h)]), e.length === l.length && (setTimeout(n), e.unbind(".imagesLoaded",
|
||||
p)))
|
||||
}
|
||||
var g = this,
|
||||
d = c.isFunction(c.Deferred) ? c.Deferred() : 0,
|
||||
r = c.isFunction(d.notify),
|
||||
e = g.find("img").add(g.filter("img")),
|
||||
l = [],
|
||||
j = [],
|
||||
h = [];
|
||||
c.isPlainObject(f) && c.each(f, function(b, a) {
|
||||
if ("callback" === b) f = a;
|
||||
else if (d) d[b](a)
|
||||
});
|
||||
e.length ? e.bind("load.imagesLoaded error.imagesLoaded", p).each(function(b, a) {
|
||||
var d = a.src,
|
||||
e = c.data(a, "imagesLoaded");
|
||||
if (e && e.src === d) k(a, e.isBroken);
|
||||
else if (a.complete && a.naturalWidth !== q) k(a, 0 === a.naturalWidth || 0 === a.naturalHeight);
|
||||
else if (a.readyState || a.complete) a.src = m, a.src = d
|
||||
}) :
|
||||
n();
|
||||
return d ? d.promise(g) : g
|
||||
}
|
||||
})(jQuery);
|
||||
|
||||
;
|
||||
(function($) {
|
||||
"use strict";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user