skrollr-rails 0.6.27 → 0.6.28

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ece143bcbb7e53716091bb2c3aa5e4106c862faa
4
- data.tar.gz: c9304911e110bb764a56ea44fd6114cf95afe937
3
+ metadata.gz: aa9d428c9c602aa99a62d2a221fa9264bc99b884
4
+ data.tar.gz: fe2a766c787113a571fed7d4d0815f20205a47d9
5
5
  SHA512:
6
- metadata.gz: 316f64c652cdb2174257732d64c68bde2a04a2a672e2339745fbff32396f97178bd5077bd4984581509e91b5bb3354fd326c56a04e076208589c1ffea88a62a5
7
- data.tar.gz: 823ab0805ecca0ab882c16fb3aa3ef7ca06837bb3211c4c0ea0df250b7bb84f650b1a81ddfe98b1d5beba15751115faefdcdce542cb5bf8e417e50de587de7ce
6
+ metadata.gz: 495245976b9495a0b327e70fc17d589ded15b13e8d965fb2a3d69697d81e0ac47ba8d1852e1ee16dcc57a81d482c9a77a638e70b5f426f00c3ba6a7ffbff1f42
7
+ data.tar.gz: 30bd98fe054124cc40fe5e131f87d185b4b63f1a298f9b1cfd4ab26e9dc48630c2c68c3d733e6216cdd004954c01d3b2d16fb5ea185df409e90a020cc9cf4332
@@ -1,5 +1,5 @@
1
1
  module Skrollr
2
2
  module Rails
3
- VERSION = "0.6.27"
3
+ VERSION = "0.6.28"
4
4
  end
5
5
  end
@@ -19,7 +19,7 @@
19
19
  init: function(options) {
20
20
  return _instance || new Skrollr(options);
21
21
  },
22
- VERSION: '0.6.27'
22
+ VERSION: '0.6.28'
23
23
  };
24
24
 
25
25
  //Minify optimization.
@@ -1566,8 +1566,14 @@
1566
1566
  * Returns the height of the document.
1567
1567
  */
1568
1568
  var _getDocumentHeight = function() {
1569
- var skrollrBodyHeight = (_skrollrBody && _skrollrBody.offsetHeight || 0);
1570
- var bodyHeight = Math.max(skrollrBodyHeight, body.scrollHeight, body.offsetHeight, documentElement.scrollHeight, documentElement.offsetHeight, documentElement.clientHeight);
1569
+ var skrollrBodyHeight = 0;
1570
+ var bodyHeight;
1571
+
1572
+ if(_skrollrBody) {
1573
+ skrollrBodyHeight = Math.max(_skrollrBody.offsetHeight, _skrollrBody.scrollHeight);
1574
+ }
1575
+
1576
+ bodyHeight = Math.max(skrollrBodyHeight, body.scrollHeight, body.offsetHeight, documentElement.scrollHeight, documentElement.offsetHeight, documentElement.clientHeight);
1571
1577
 
1572
1578
  return bodyHeight - documentElement.clientHeight;
1573
1579
  };
@@ -15,6 +15,7 @@
15
15
 
16
16
  var MENU_TOP_ATTR = 'data-menu-top';
17
17
  var MENU_OFFSET_ATTR = 'data-menu-offset';
18
+ var MENU_DURATION_ATTR = 'data-menu-duration';
18
19
 
19
20
  var skrollr = window.skrollr;
20
21
  var history = window.history;
@@ -65,11 +66,28 @@
65
66
  When the fake flag is set, the link won't change the url and the position won't be animated.
66
67
  */
67
68
  var handleLink = function(link, fake) {
68
- //Don't use the href property (link.href) because it contains the absolute url.
69
- var href = link.getAttribute('href');
69
+ var hash;
70
70
 
71
- //Check if it's a hashlink.
72
- if(!/^#/.test(href)) {
71
+ //When complexLinks is enabled, we also accept links which do not just contain a simple hash.
72
+ if(_complexLinks) {
73
+ //The link points to something completely different.
74
+ if(link.hostname !== window.location.hostname) {
75
+ return false;
76
+ }
77
+
78
+ //The link does not link to the same page/path.
79
+ if(link.pathname !== document.location.pathname) {
80
+ return false;
81
+ }
82
+
83
+ hash = link.hash;
84
+ } else {
85
+ //Don't use the href property (link.href) because it contains the absolute url.
86
+ hash = link.getAttribute('href');
87
+ }
88
+
89
+ //Not a hash link.
90
+ if(!/^#/.test(hash)) {
73
91
  return false;
74
92
  }
75
93
 
@@ -95,7 +113,7 @@
95
113
  targetTop = +menuTop * _scale;
96
114
  }
97
115
  } else {
98
- var scrollTarget = document.getElementById(href.substr(1));
116
+ var scrollTarget = document.getElementById(hash.substr(1));
99
117
 
100
118
  //Ignore the click if no target is found.
101
119
  if(!scrollTarget) {
@@ -112,13 +130,20 @@
112
130
  }
113
131
 
114
132
  if(supportsHistory && !fake) {
115
- history.pushState({top: targetTop}, '', href);
133
+ history.pushState({top: targetTop}, '', hash);
134
+ }
135
+
136
+ var menuDuration = parseInt(link.getAttribute(MENU_DURATION_ATTR), 10);
137
+ var animationDuration = _duration(_skrollrInstance.getScrollTop(), targetTop);
138
+
139
+ if(!isNaN(menuDuration)) {
140
+ animationDuration = menuDuration;
116
141
  }
117
142
 
118
143
  //Now finally scroll there.
119
144
  if(_animate && !fake) {
120
145
  _skrollrInstance.animateTo(targetTop, {
121
- duration: _duration(_skrollrInstance.getScrollTop(), targetTop),
146
+ duration: animationDuration,
122
147
  easing: _easing
123
148
  });
124
149
  } else {
@@ -162,6 +187,7 @@
162
187
  _duration = options.duration || DEFAULT_DURATION;
163
188
  _handleLink = options.handleLink;
164
189
  _scale = options.scale || DEFAULT_SCALE;
190
+ _complexLinks = options.complexLinks === true;
165
191
 
166
192
  if(typeof _duration === 'number') {
167
193
  _duration = (function(duration) {
@@ -202,6 +228,7 @@
202
228
  var _animate;
203
229
  var _handleLink;
204
230
  var _scale;
231
+ var _complexLinks;
205
232
 
206
233
  //In case the page was opened with a hash, prevent jumping to it.
207
234
  //http://stackoverflow.com/questions/3659072/jquery-disable-anchor-jump-when-loading-a-page
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skrollr-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.27
4
+ version: 0.6.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Reed