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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 90d42417145d958f9102ab7ee99899f721754dff
4
- data.tar.gz: f15af88c38511803b0f16811ecba118b3edc711c
3
+ metadata.gz: 4db29400200f071fbcfc877b08cd0c488c4c2a10
4
+ data.tar.gz: fb0295e03a0b6f94a3c62a2de0ae8fb356e36d55
5
5
  SHA512:
6
- metadata.gz: ad0aeebf2cf78ddbb6eaac6e5ac4e23c482387c383e4f352f25663619c515fdff24305eb4a0ee1b32eea8f1732ff986c0406be7d641ed1df9ae88216d07f8201
7
- data.tar.gz: 0f329a0827b755a551a013539c4a9105823aa9054e33b0c0b05c70614ae72a1ea41b8b7a823d98effa6613379d7a253ac75b744d236e53dee54ea7384e264066
6
+ metadata.gz: 54fee4ed342e20cb9884fa011d0900a4730338224f4ed67b3c27315947f9a8dbcc81bf733b73797b4329963b2cfa531660cd7bf4eb5e3f5ec85bb34b7dfd86ce
7
+ data.tar.gz: 5246968443f9af3143b3a3efeafe1b120c5ee36d25e8d85c93113b8398a342d654739460efb47a33ead251d6d30f9730037b19e45928666c0c1f90c3f0dc62d9
@@ -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);
@@ -0,0 +1,4 @@
1
+ //= require jquery.unveil
2
+ $(document).ready(function() {
3
+ $('img').unveil(<%= Unveil::Rails.config.threshold %>);
4
+ });
@@ -1,5 +1,5 @@
1
1
  module Unveil
2
2
  class Rails
3
- VERSION='0.2.1'
3
+ VERSION='0.2.2'
4
4
  end
5
5
  end
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.1
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-06-09 00:00:00.000000000 Z
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