unveil-rails 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/unveil/assets/blank.gif +0 -0
- data/lib/unveil/assets/jquery.unveil.js +56 -0
- data/lib/unveil/assets/unveil_init.js.erb +4 -0
- data/lib/unveil/rails/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4db29400200f071fbcfc877b08cd0c488c4c2a10
|
4
|
+
data.tar.gz: fb0295e03a0b6f94a3c62a2de0ae8fb356e36d55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54fee4ed342e20cb9884fa011d0900a4730338224f4ed67b3c27315947f9a8dbcc81bf733b73797b4329963b2cfa531660cd7bf4eb5e3f5ec85bb34b7dfd86ce
|
7
|
+
data.tar.gz: 5246968443f9af3143b3a3efeafe1b120c5ee36d25e8d85c93113b8398a342d654739460efb47a33ead251d6d30f9730037b19e45928666c0c1f90c3f0dc62d9
|
Binary file
|
@@ -0,0 +1,56 @@
|
|
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
|
+
;(function($) {
|
12
|
+
|
13
|
+
$.fn.unveil = function(threshold, callback) {
|
14
|
+
|
15
|
+
var $w = $(window),
|
16
|
+
th = threshold || 0,
|
17
|
+
retina = window.devicePixelRatio > 1,
|
18
|
+
attrib = retina? "data-src-retina" : "data-src",
|
19
|
+
images = this,
|
20
|
+
loaded;
|
21
|
+
|
22
|
+
this.one("unveil", function() {
|
23
|
+
var source = this.getAttribute(attrib);
|
24
|
+
source = source || this.getAttribute("data-src");
|
25
|
+
if (source) {
|
26
|
+
this.setAttribute("src", source);
|
27
|
+
if (typeof callback === "function") callback.call(this);
|
28
|
+
}
|
29
|
+
});
|
30
|
+
|
31
|
+
function unveil() {
|
32
|
+
var inview = images.filter(function() {
|
33
|
+
var $e = $(this);
|
34
|
+
if ($e.is(":hidden")) return;
|
35
|
+
|
36
|
+
var wt = $w.scrollTop(),
|
37
|
+
wb = wt + $w.height(),
|
38
|
+
et = $e.offset().top,
|
39
|
+
eb = et + $e.height();
|
40
|
+
|
41
|
+
return eb >= wt - th && et <= wb + th;
|
42
|
+
});
|
43
|
+
|
44
|
+
loaded = inview.trigger("unveil");
|
45
|
+
images = images.not(loaded);
|
46
|
+
}
|
47
|
+
|
48
|
+
$w.on("scroll.unveil resize.unveil lookup.unveil", unveil);
|
49
|
+
|
50
|
+
unveil();
|
51
|
+
|
52
|
+
return this;
|
53
|
+
|
54
|
+
};
|
55
|
+
|
56
|
+
})(window.jQuery || window.Zepto);
|
data/lib/unveil/rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unveil-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Morton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -62,6 +62,9 @@ files:
|
|
62
62
|
- LICENSE
|
63
63
|
- README.md
|
64
64
|
- lib/unveil-rails.rb
|
65
|
+
- lib/unveil/assets/blank.gif
|
66
|
+
- lib/unveil/assets/jquery.unveil.js
|
67
|
+
- lib/unveil/assets/unveil_init.js.erb
|
65
68
|
- lib/unveil/rails.rb
|
66
69
|
- lib/unveil/rails/config.rb
|
67
70
|
- lib/unveil/rails/install_generator.rb
|