skrollr-rails 0.6.4 → 0.6.5

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: 77f887e7dbbdcae40eecde8fe3b75d435e56f7b8
4
- data.tar.gz: 34706973c35618bf5d62a0f23590ea5a148e163a
3
+ metadata.gz: fc392484b2d622dfbdc8c4ea6e03a3b5eeb8f8e5
4
+ data.tar.gz: 6c69ff25ca905d70b40f68f05c72026e515c8e2f
5
5
  SHA512:
6
- metadata.gz: 5e0b66ec9be55fce54c96594731c75a58eeb7d0c39c9a64cba02a0f7fecf91ee15beeccd4a38f4c1d99226e7671ff49cd629c3cdd70e47ef3958599f9829ef7a
7
- data.tar.gz: 7bb38a3b041c0b5842b9be964f25f7c41e7fdca4f4b8cc4499261b99171eee7d04f01f53f397638be049fe1860ff65ddbdd10cd7c133ecc7e53f132be51e568a
6
+ metadata.gz: 3acb1b7751e38c669a7e4f95f121238b16f0b17f9faabcb52b57c5d6e1acbc85caa6ea4a0b6ab44458bc342fb52a6369d0e9304ec81ba0f4813b3a4593ee2d41
7
+ data.tar.gz: e119e409da9733d5a757c1cffbad6d3d19ddd6243f94ae835545a4e8e779fc684d33208dccf041a98e421d092e2b48b84db157efd152c5f45600e8530a1477ef
@@ -1,5 +1,5 @@
1
1
  module Skrollr
2
2
  module Rails
3
- VERSION = "0.6.4"
3
+ VERSION = "0.6.5"
4
4
  end
5
5
  end
@@ -5,120 +5,119 @@
5
5
  * Alexander Prinzhorn - https://github.com/Prinzhorn/skrollr
6
6
  *
7
7
  * Free to use under terms of MIT license
8
- */ (function(document, skrollr) {
9
- 'use strict';
10
-
11
- var rxHSLAColor = /hsla?\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)%\s*,\s*(-?[\d.]+)%.*?\)/g;
12
- var rxRGBAColor = /rgba?\(\s*(-?[\d.]+%?)\s*,\s*(-?[\d.]+%?)\s*,\s*(-?[\d.]+%?).*?\)/g;
13
- var rxID = /^#[^\s]+$/;
14
-
15
- var _setStyle = skrollr.setStyle;
16
-
17
- //Monkeypatch the setStyle function.
18
- skrollr.setStyle = function(el, prop, val) {
19
- //Original function call.
20
- _setStyle.apply(this, arguments);
21
-
22
- var style = el.style;
23
- var matched;
24
-
25
- //IE opacity
26
- if (prop === 'opacity') {
27
- style.zoom = 1;
28
-
29
- //Remove filter attribute in IE
30
- if (val >= 1 && style.removeAttribute) {
31
- style.removeAttribute('filter');
32
- } else {
33
- style.filter = 'alpha(opacity=' + val * 100 + ')';
34
- }
35
-
36
- return;
37
- }
38
-
39
- //Fast pre check
40
- if (val.indexOf('hsl') > -1) {
41
- matched = false;
42
-
43
- //Replace hsl(a) with hex if needed (ignoring alpha).
44
- val = val.replace(rxHSLAColor, function(x, h, s, l) {
45
- matched = true;
46
-
47
- return toHex.hsl(parseFloat(h), parseFloat(s), parseFloat(l));
48
- });
49
-
50
- if (matched) {
51
- try {
52
- style[prop] = val;
53
- } catch (ignore) {}
54
-
55
- return;
56
- }
57
- }
58
-
59
- //Fast pre check
60
- if (val.indexOf('rgb') > -1) {
61
- matched = false;
62
-
63
- //Replace rgba with hex if needed (ignoring alpha).
64
- val = val.replace(rxRGBAColor, function(s, r, g, b) {
65
- matched = true;
66
-
67
- r = parseFloat(r, 10);
68
- g = parseFloat(g, 10);
69
- b = parseFloat(b, 10);
70
-
71
- //rgba allows percentage notation.
72
- if (s.indexOf('%') > -1) {
73
- r = (r / 100) * 255;
74
- g = (g / 100) * 255;
75
- b = (b / 100) * 255;
76
- }
77
-
78
- return toHex.rgb(r | 0, g | 0, b | 0);
79
- });
80
-
81
- if (matched) {
82
- try {
83
- style[prop] = val;
84
- } catch (ignore) {}
85
-
86
- return;
87
- }
88
- }
89
- };
90
-
91
-
92
- /**
93
- * Converts rgb or hsl color to hex color.
94
- */
95
- var toHex = {
96
- //Credits to aemkei, jed and others
97
- //Based on https://gist.github.com/1325937 and https://gist.github.com/983535
98
- hsl: function(a, b, c, y) {
99
- a %= 360;
100
- a = a / 60;
101
- c = c / 100;
102
- b = [c += b *= (c < 0.5 ? c : 1 - c) / 100, c - a % 1 * b * 2, c -= b *= 2, c, c + a % 1 * b, c + b];
103
-
104
- y = [b[~~a % 6], b[(a | 16) % 6], b[(a | 8) % 6]];
105
-
106
- return toHex.rgb(parseInt(y[0] * 255, 10), parseInt(y[1] * 255, 10), parseInt(y[2] * 255, 10));
107
- },
108
- //https://gist.github.com/983535
109
- rgb: function(a, b, c) {
110
- return '#' + ((256 + a << 8 | b) << 8 | c).toString(16).slice(1);
111
- }
112
- };
113
-
114
- /*
8
+ */
9
+ (function(document, skrollr) {
10
+ 'use strict';
11
+
12
+ var rxHSLAColor = /hsla?\(\s*(-?[\d.]+)\s*,\s*(-?[\d.]+)%\s*,\s*(-?[\d.]+)%.*?\)/g;
13
+ var rxRGBAColor = /rgba?\(\s*(-?[\d.]+%?)\s*,\s*(-?[\d.]+%?)\s*,\s*(-?[\d.]+%?).*?\)/g;
14
+ var rxID = /^#[^\s]+$/;
15
+
16
+ var _setStyle = skrollr.setStyle;
17
+
18
+ //Monkeypatch the setStyle function.
19
+ skrollr.setStyle = function(el, prop, val) {
20
+ //Original function call.
21
+ _setStyle.apply(this, arguments);
22
+
23
+ var style = el.style;
24
+ var matched;
25
+
26
+ //IE opacity
27
+ if(prop === 'opacity') {
28
+ style.zoom = 1;
29
+
30
+ //Remove filter attribute in IE
31
+ if(val >= 1 && style.removeAttribute) {
32
+ style.removeAttribute('filter');
33
+ } else {
34
+ style.filter = 'alpha(opacity=' + val * 100 + ')';
35
+ }
36
+
37
+ return;
38
+ }
39
+
40
+ //Fast pre check
41
+ if(val.indexOf('hsl') > -1) {
42
+ matched = false;
43
+
44
+ //Replace hsl(a) with hex if needed (ignoring alpha).
45
+ val = val.replace(rxHSLAColor, function(x, h, s, l) {
46
+ matched = true;
47
+
48
+ return toHex.hsl(parseFloat(h), parseFloat(s), parseFloat(l));
49
+ });
50
+
51
+ if(matched) {
52
+ try {
53
+ style[prop] = val;
54
+ } catch(ignore) {}
55
+
56
+ return;
57
+ }
58
+ }
59
+
60
+ //Fast pre check
61
+ if(val.indexOf('rgb') > -1) {
62
+ matched = false;
63
+
64
+ //Replace rgba with hex if needed (ignoring alpha).
65
+ val = val.replace(rxRGBAColor, function(s, r, g, b) {
66
+ matched = true;
67
+
68
+ r = parseFloat(r, 10);
69
+ g = parseFloat(g, 10);
70
+ b = parseFloat(b, 10);
71
+
72
+ //rgba allows percentage notation.
73
+ if(s.indexOf('%') > -1) {
74
+ r = (r / 100) * 255;
75
+ g = (g / 100) * 255;
76
+ b = (b / 100) * 255;
77
+ }
78
+
79
+ return toHex.rgb(r | 0, g | 0, b | 0);
80
+ });
81
+
82
+ if(matched) {
83
+ try {
84
+ style[prop] = val;
85
+ } catch(ignore) {}
86
+
87
+ return;
88
+ }
89
+ }
90
+ };
91
+
92
+
93
+ /**
94
+ * Converts rgb or hsl color to hex color.
95
+ */
96
+ var toHex = {
97
+ //Credits to aemkei, jed and others
98
+ //Based on https://gist.github.com/1325937 and https://gist.github.com/983535
99
+ hsl: function(a,b,c,y){
100
+ a%=360;
101
+ a=a/60;c=c/100;b=[c+=b*=(c<0.5?c:1-c)/100,c-a%1*b*2,c-=b*=2,c,c+a%1*b,c+b];
102
+
103
+ y = [b[~~a%6],b[(a|16)%6],b[(a|8)%6]];
104
+
105
+ return toHex.rgb(parseInt(y[0] * 255, 10), parseInt(y[1] * 255, 10), parseInt(y[2] * 255, 10));
106
+ },
107
+ //https://gist.github.com/983535
108
+ rgb: function(a,b,c){
109
+ return'#' + ((256+a<<8|b)<<8|c).toString(16).slice(1);
110
+ }
111
+ };
112
+
113
+ /*
115
114
  A really bad polyfill. But the main use-case for data-anchor-target are IDs.
116
115
  */
117
- document.querySelector = document.querySelector || function(selector) {
118
- if (!rxID.test(selector)) {
119
- throw 'Unsupported selector "' + selector + '". The querySelector polyfill only works for IDs.';
120
- }
121
-
122
- return document.getElementById(selector.substr(1));
123
- };
124
- }(document, window.skrollr));
116
+ document.querySelector = document.querySelector || function(selector) {
117
+ if(!rxID.test(selector)) {
118
+ throw 'Unsupported selector "' + selector + '". The querySelector polyfill only works for IDs.';
119
+ }
120
+
121
+ return document.getElementById(selector.substr(1));
122
+ };
123
+ }(document, window.skrollr));