1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,47 @@ |
1 |
+# jQuery Waypoints |
|
2 |
+ |
|
3 |
+Waypoints is a jQuery plugin that makes it easy to execute a function whenever you scroll to an element. |
|
4 |
+ |
|
5 |
+```js |
|
6 |
+$('.thing').waypoint(function() { |
|
7 |
+ alert('You have scrolled to a thing.'); |
|
8 |
+}); |
|
9 |
+``` |
|
10 |
+If you're new to Waypoints, check out the [Get Started](http://imakewebthings.github.com/jquery-waypoints/#get-started) section. |
|
11 |
+ |
|
12 |
+[Read the full documentation](http://imakewebthings.github.com/jquery-waypoints/#docs) for more details on usage and customization. |
|
13 |
+ |
|
14 |
+## Shortcuts |
|
15 |
+ |
|
16 |
+In addition to the normal Waypoints script, extensions exist to make common UI patterns just a little easier to implement: |
|
17 |
+ |
|
18 |
+- [Infinite Scrolling](http://imakewebthings.github.com/jquery-waypoints/shortcuts/infinite-scroll) |
|
19 |
+- [Sticky Elements](http://imakewebthings.github.com/jquery-waypoints/shortcuts/sticky-elements) |
|
20 |
+ |
|
21 |
+## Examples |
|
22 |
+ |
|
23 |
+Waypoints can also be used as a base for your own custom UI patterns. Here are a few examples: |
|
24 |
+ |
|
25 |
+- [Scroll Analytics](http://imakewebthings.github.com/jquery-waypoints/examples/scroll-analytics) |
|
26 |
+- [Dial Controls](http://imakewebthings.github.com/jquery-waypoints/examples/dial-controls) |
|
27 |
+ |
|
28 |
+## AMD Module Loader Support |
|
29 |
+ |
|
30 |
+If you're using an AMD loader like [RequireJS](http://requirejs.org/), Waypoints registers itself as a named module, `'waypoints'`. Shortcut scripts are anonymous modules. |
|
31 |
+ |
|
32 |
+## Development Environment |
|
33 |
+ |
|
34 |
+If you want to contribute to Waypoints, I love pull requests that include changes to the source `coffee` files as well as the compiled JS and minified files. You can set up the same environment by running `make setup` (which just aliases to `npm install`). This will install the version of CoffeeScript and UglifyJS that I'm using. From there, running `make build` will compile and minify all the necessary files. Test coffee files are compiled on the fly, so compile and minify do not apply to those files. |
|
35 |
+ |
|
36 |
+## License |
|
37 |
+ |
|
38 |
+Copyright (c) 2011-2014 Caleb Troughton |
|
39 |
+Licensed under the [MIT license](https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt). |
|
40 |
+ |
|
41 |
+## Support |
|
42 |
+ |
|
43 |
+Unit tests for Waypoints are written with [Jasmine](http://pivotal.github.com/jasmine/) and [jasmine-jquery](https://github.com/velesin/jasmine-jquery). You can [run them here](http://imakewebthings.github.com/jquery-waypoints/test/). If any of the tests fail, please open an issue and include the browser used, operating system, and description of the failed test. |
|
44 |
+ |
|
45 |
+## Donations |
|
46 |
+ |
|
47 |
+[](https://www.gittip.com/imakewebthings/ "Donate weekly to this project using Gittip") |
1 | 4 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,520 @@ |
1 |
+// Generated by CoffeeScript 1.6.2 |
|
2 |
+/* |
|
3 |
+jQuery Waypoints - v2.0.4 |
|
4 |
+Copyright (c) 2011-2014 Caleb Troughton |
|
5 |
+Dual licensed under the MIT license and GPL license. |
|
6 |
+https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt |
|
7 |
+*/ |
|
8 |
+ |
|
9 |
+ |
|
10 |
+(function() { |
|
11 |
+ var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, |
|
12 |
+ __slice = [].slice; |
|
13 |
+ |
|
14 |
+ (function(root, factory) { |
|
15 |
+ if (typeof define === 'function' && define.amd) { |
|
16 |
+ return define('waypoints', ['jquery'], function($) { |
|
17 |
+ return factory($, root); |
|
18 |
+ }); |
|
19 |
+ } else { |
|
20 |
+ return factory(root.jQuery, root); |
|
21 |
+ } |
|
22 |
+ })(this, function($, window) { |
|
23 |
+ var $w, Context, Waypoint, allWaypoints, contextCounter, contextKey, contexts, isTouch, jQMethods, methods, resizeEvent, scrollEvent, waypointCounter, waypointKey, wp, wps; |
|
24 |
+ |
|
25 |
+ $w = $(window); |
|
26 |
+ isTouch = __indexOf.call(window, 'ontouchstart') >= 0; |
|
27 |
+ allWaypoints = { |
|
28 |
+ horizontal: {}, |
|
29 |
+ vertical: {} |
|
30 |
+ }; |
|
31 |
+ contextCounter = 1; |
|
32 |
+ contexts = {}; |
|
33 |
+ contextKey = 'waypoints-context-id'; |
|
34 |
+ resizeEvent = 'resize.waypoints'; |
|
35 |
+ scrollEvent = 'scroll.waypoints'; |
|
36 |
+ waypointCounter = 1; |
|
37 |
+ waypointKey = 'waypoints-waypoint-ids'; |
|
38 |
+ wp = 'waypoint'; |
|
39 |
+ wps = 'waypoints'; |
|
40 |
+ Context = (function() { |
|
41 |
+ function Context($element) { |
|
42 |
+ var _this = this; |
|
43 |
+ |
|
44 |
+ this.$element = $element; |
|
45 |
+ this.element = $element[0]; |
|
46 |
+ this.didResize = false; |
|
47 |
+ this.didScroll = false; |
|
48 |
+ this.id = 'context' + contextCounter++; |
|
49 |
+ this.oldScroll = { |
|
50 |
+ x: $element.scrollLeft(), |
|
51 |
+ y: $element.scrollTop() |
|
52 |
+ }; |
|
53 |
+ this.waypoints = { |
|
54 |
+ horizontal: {}, |
|
55 |
+ vertical: {} |
|
56 |
+ }; |
|
57 |
+ this.element[contextKey] = this.id; |
|
58 |
+ contexts[this.id] = this; |
|
59 |
+ $element.bind(scrollEvent, function() { |
|
60 |
+ var scrollHandler; |
|
61 |
+ |
|
62 |
+ if (!(_this.didScroll || isTouch)) { |
|
63 |
+ _this.didScroll = true; |
|
64 |
+ scrollHandler = function() { |
|
65 |
+ _this.doScroll(); |
|
66 |
+ return _this.didScroll = false; |
|
67 |
+ }; |
|
68 |
+ return window.setTimeout(scrollHandler, $[wps].settings.scrollThrottle); |
|
69 |
+ } |
|
70 |
+ }); |
|
71 |
+ $element.bind(resizeEvent, function() { |
|
72 |
+ var resizeHandler; |
|
73 |
+ |
|
74 |
+ if (!_this.didResize) { |
|
75 |
+ _this.didResize = true; |
|
76 |
+ resizeHandler = function() { |
|
77 |
+ $[wps]('refresh'); |
|
78 |
+ return _this.didResize = false; |
|
79 |
+ }; |
|
80 |
+ return window.setTimeout(resizeHandler, $[wps].settings.resizeThrottle); |
|
81 |
+ } |
|
82 |
+ }); |
|
83 |
+ } |
|
84 |
+ |
|
85 |
+ Context.prototype.doScroll = function() { |
|
86 |
+ var axes, |
|
87 |
+ _this = this; |
|
88 |
+ |
|
89 |
+ axes = { |
|
90 |
+ horizontal: { |
|
91 |
+ newScroll: this.$element.scrollLeft(), |
|
92 |
+ oldScroll: this.oldScroll.x, |
|
93 |
+ forward: 'right', |
|
94 |
+ backward: 'left' |
|
95 |
+ }, |
|
96 |
+ vertical: { |
|
97 |
+ newScroll: this.$element.scrollTop(), |
|
98 |
+ oldScroll: this.oldScroll.y, |
|
99 |
+ forward: 'down', |
|
100 |
+ backward: 'up' |
|
101 |
+ } |
|
102 |
+ }; |
|
103 |
+ if (isTouch && (!axes.vertical.oldScroll || !axes.vertical.newScroll)) { |
|
104 |
+ $[wps]('refresh'); |
|
105 |
+ } |
|
106 |
+ $.each(axes, function(aKey, axis) { |
|
107 |
+ var direction, isForward, triggered; |
|
108 |
+ |
|
109 |
+ triggered = []; |
|
110 |
+ isForward = axis.newScroll > axis.oldScroll; |
|
111 |
+ direction = isForward ? axis.forward : axis.backward; |
|
112 |
+ $.each(_this.waypoints[aKey], function(wKey, waypoint) { |
|
113 |
+ var _ref, _ref1; |
|
114 |
+ |
|
115 |
+ if ((axis.oldScroll < (_ref = waypoint.offset) && _ref <= axis.newScroll)) { |
|
116 |
+ return triggered.push(waypoint); |
|
117 |
+ } else if ((axis.newScroll < (_ref1 = waypoint.offset) && _ref1 <= axis.oldScroll)) { |
|
118 |
+ return triggered.push(waypoint); |
|
119 |
+ } |
|
120 |
+ }); |
|
121 |
+ triggered.sort(function(a, b) { |
|
122 |
+ return a.offset - b.offset; |
|
123 |
+ }); |
|
124 |
+ if (!isForward) { |
|
125 |
+ triggered.reverse(); |
|
126 |
+ } |
|
127 |
+ return $.each(triggered, function(i, waypoint) { |
|
128 |
+ if (waypoint.options.continuous || i === triggered.length - 1) { |
|
129 |
+ return waypoint.trigger([direction]); |
|
130 |
+ } |
|
131 |
+ }); |
|
132 |
+ }); |
|
133 |
+ return this.oldScroll = { |
|
134 |
+ x: axes.horizontal.newScroll, |
|
135 |
+ y: axes.vertical.newScroll |
|
136 |
+ }; |
|
137 |
+ }; |
|
138 |
+ |
|
139 |
+ Context.prototype.refresh = function() { |
|
140 |
+ var axes, cOffset, isWin, |
|
141 |
+ _this = this; |
|
142 |
+ |
|
143 |
+ isWin = $.isWindow(this.element); |
|
144 |
+ cOffset = this.$element.offset(); |
|
145 |
+ this.doScroll(); |
|
146 |
+ axes = { |
|
147 |
+ horizontal: { |
|
148 |
+ contextOffset: isWin ? 0 : cOffset.left, |
|
149 |
+ contextScroll: isWin ? 0 : this.oldScroll.x, |
|
150 |
+ contextDimension: this.$element.width(), |
|
151 |
+ oldScroll: this.oldScroll.x, |
|
152 |
+ forward: 'right', |
|
153 |
+ backward: 'left', |
|
154 |
+ offsetProp: 'left' |
|
155 |
+ }, |
|
156 |
+ vertical: { |
|
157 |
+ contextOffset: isWin ? 0 : cOffset.top, |
|
158 |
+ contextScroll: isWin ? 0 : this.oldScroll.y, |
|
159 |
+ contextDimension: isWin ? $[wps]('viewportHeight') : this.$element.height(), |
|
160 |
+ oldScroll: this.oldScroll.y, |
|
161 |
+ forward: 'down', |
|
162 |
+ backward: 'up', |
|
163 |
+ offsetProp: 'top' |
|
164 |
+ } |
|
165 |
+ }; |
|
166 |
+ return $.each(axes, function(aKey, axis) { |
|
167 |
+ return $.each(_this.waypoints[aKey], function(i, waypoint) { |
|
168 |
+ var adjustment, elementOffset, oldOffset, _ref, _ref1; |
|
169 |
+ |
|
170 |
+ adjustment = waypoint.options.offset; |
|
171 |
+ oldOffset = waypoint.offset; |
|
172 |
+ elementOffset = $.isWindow(waypoint.element) ? 0 : waypoint.$element.offset()[axis.offsetProp]; |
|
173 |
+ if ($.isFunction(adjustment)) { |
|
174 |
+ adjustment = adjustment.apply(waypoint.element); |
|
175 |
+ } else if (typeof adjustment === 'string') { |
|
176 |
+ adjustment = parseFloat(adjustment); |
|
177 |
+ if (waypoint.options.offset.indexOf('%') > -1) { |
|
178 |
+ adjustment = Math.ceil(axis.contextDimension * adjustment / 100); |
|
179 |
+ } |
|
180 |
+ } |
|
181 |
+ waypoint.offset = elementOffset - axis.contextOffset + axis.contextScroll - adjustment; |
|
182 |
+ if ((waypoint.options.onlyOnScroll && (oldOffset != null)) || !waypoint.enabled) { |
|
183 |
+ return; |
|
184 |
+ } |
|
185 |
+ if (oldOffset !== null && (oldOffset < (_ref = axis.oldScroll) && _ref <= waypoint.offset)) { |
|
186 |
+ return waypoint.trigger([axis.backward]); |
|
187 |
+ } else if (oldOffset !== null && (oldOffset > (_ref1 = axis.oldScroll) && _ref1 >= waypoint.offset)) { |
|
188 |
+ return waypoint.trigger([axis.forward]); |
|
189 |
+ } else if (oldOffset === null && axis.oldScroll >= waypoint.offset) { |
|
190 |
+ return waypoint.trigger([axis.forward]); |
|
191 |
+ } |
|
192 |
+ }); |
|
193 |
+ }); |
|
194 |
+ }; |
|
195 |
+ |
|
196 |
+ Context.prototype.checkEmpty = function() { |
|
197 |
+ if ($.isEmptyObject(this.waypoints.horizontal) && $.isEmptyObject(this.waypoints.vertical)) { |
|
198 |
+ this.$element.unbind([resizeEvent, scrollEvent].join(' ')); |
|
199 |
+ return delete contexts[this.id]; |
|
200 |
+ } |
|
201 |
+ }; |
|
202 |
+ |
|
203 |
+ return Context; |
|
204 |
+ |
|
205 |
+ })(); |
|
206 |
+ Waypoint = (function() { |
|
207 |
+ function Waypoint($element, context, options) { |
|
208 |
+ var idList, _ref; |
|
209 |
+ |
|
210 |
+ options = $.extend({}, $.fn[wp].defaults, options); |
|
211 |
+ if (options.offset === 'bottom-in-view') { |
|
212 |
+ options.offset = function() { |
|
213 |
+ var contextHeight; |
|
214 |
+ |
|
215 |
+ contextHeight = $[wps]('viewportHeight'); |
|
216 |
+ if (!$.isWindow(context.element)) { |
|
217 |
+ contextHeight = context.$element.height(); |
|
218 |
+ } |
|
219 |
+ return contextHeight - $(this).outerHeight(); |
|
220 |
+ }; |
|
221 |
+ } |
|
222 |
+ this.$element = $element; |
|
223 |
+ this.element = $element[0]; |
|
224 |
+ this.axis = options.horizontal ? 'horizontal' : 'vertical'; |
|
225 |
+ this.callback = options.handler; |
|
226 |
+ this.context = context; |
|
227 |
+ this.enabled = options.enabled; |
|
228 |
+ this.id = 'waypoints' + waypointCounter++; |
|
229 |
+ this.offset = null; |
|
230 |
+ this.options = options; |
|
231 |
+ context.waypoints[this.axis][this.id] = this; |
|
232 |
+ allWaypoints[this.axis][this.id] = this; |
|
233 |
+ idList = (_ref = this.element[waypointKey]) != null ? _ref : []; |
|
234 |
+ idList.push(this.id); |
|
235 |
+ this.element[waypointKey] = idList; |
|
236 |
+ } |
|
237 |
+ |
|
238 |
+ Waypoint.prototype.trigger = function(args) { |
|
239 |
+ if (!this.enabled) { |
|
240 |
+ return; |
|
241 |
+ } |
|
242 |
+ if (this.callback != null) { |
|
243 |
+ this.callback.apply(this.element, args); |
|
244 |
+ } |
|
245 |
+ if (this.options.triggerOnce) { |
|
246 |
+ return this.destroy(); |
|
247 |
+ } |
|
248 |
+ }; |
|
249 |
+ |
|
250 |
+ Waypoint.prototype.disable = function() { |
|
251 |
+ return this.enabled = false; |
|
252 |
+ }; |
|
253 |
+ |
|
254 |
+ Waypoint.prototype.enable = function() { |
|
255 |
+ this.context.refresh(); |
|
256 |
+ return this.enabled = true; |
|
257 |
+ }; |
|
258 |
+ |
|
259 |
+ Waypoint.prototype.destroy = function() { |
|
260 |
+ delete allWaypoints[this.axis][this.id]; |
|
261 |
+ delete this.context.waypoints[this.axis][this.id]; |
|
262 |
+ return this.context.checkEmpty(); |
|
263 |
+ }; |
|
264 |
+ |
|
265 |
+ Waypoint.getWaypointsByElement = function(element) { |
|
266 |
+ var all, ids; |
|
267 |
+ |
|
268 |
+ ids = element[waypointKey]; |
|
269 |
+ if (!ids) { |
|
270 |
+ return []; |
|
271 |
+ } |
|
272 |
+ all = $.extend({}, allWaypoints.horizontal, allWaypoints.vertical); |
|
273 |
+ return $.map(ids, function(id) { |
|
274 |
+ return all[id]; |
|
275 |
+ }); |
|
276 |
+ }; |
|
277 |
+ |
|
278 |
+ return Waypoint; |
|
279 |
+ |
|
280 |
+ })(); |
|
281 |
+ methods = { |
|
282 |
+ init: function(f, options) { |
|
283 |
+ var _ref; |
|
284 |
+ |
|
285 |
+ if (options == null) { |
|
286 |
+ options = {}; |
|
287 |
+ } |
|
288 |
+ if ((_ref = options.handler) == null) { |
|
289 |
+ options.handler = f; |
|
290 |
+ } |
|
291 |
+ this.each(function() { |
|
292 |
+ var $this, context, contextElement, _ref1; |
|
293 |
+ |
|
294 |
+ $this = $(this); |
|
295 |
+ contextElement = (_ref1 = options.context) != null ? _ref1 : $.fn[wp].defaults.context; |
|
296 |
+ if (!$.isWindow(contextElement)) { |
|
297 |
+ contextElement = $this.closest(contextElement); |
|
298 |
+ } |
|
299 |
+ contextElement = $(contextElement); |
|
300 |
+ context = contexts[contextElement[0][contextKey]]; |
|
301 |
+ if (!context) { |
|
302 |
+ context = new Context(contextElement); |
|
303 |
+ } |
|
304 |
+ return new Waypoint($this, context, options); |
|
305 |
+ }); |
|
306 |
+ $[wps]('refresh'); |
|
307 |
+ return this; |
|
308 |
+ }, |
|
309 |
+ disable: function() { |
|
310 |
+ return methods._invoke.call(this, 'disable'); |
|
311 |
+ }, |
|
312 |
+ enable: function() { |
|
313 |
+ return methods._invoke.call(this, 'enable'); |
|
314 |
+ }, |
|
315 |
+ destroy: function() { |
|
316 |
+ return methods._invoke.call(this, 'destroy'); |
|
317 |
+ }, |
|
318 |
+ prev: function(axis, selector) { |
|
319 |
+ return methods._traverse.call(this, axis, selector, function(stack, index, waypoints) { |
|
320 |
+ if (index > 0) { |
|
321 |
+ return stack.push(waypoints[index - 1]); |
|
322 |
+ } |
|
323 |
+ }); |
|
324 |
+ }, |
|
325 |
+ next: function(axis, selector) { |
|
326 |
+ return methods._traverse.call(this, axis, selector, function(stack, index, waypoints) { |
|
327 |
+ if (index < waypoints.length - 1) { |
|
328 |
+ return stack.push(waypoints[index + 1]); |
|
329 |
+ } |
|
330 |
+ }); |
|
331 |
+ }, |
|
332 |
+ _traverse: function(axis, selector, push) { |
|
333 |
+ var stack, waypoints; |
|
334 |
+ |
|
335 |
+ if (axis == null) { |
|
336 |
+ axis = 'vertical'; |
|
337 |
+ } |
|
338 |
+ if (selector == null) { |
|
339 |
+ selector = window; |
|
340 |
+ } |
|
341 |
+ waypoints = jQMethods.aggregate(selector); |
|
342 |
+ stack = []; |
|
343 |
+ this.each(function() { |
|
344 |
+ var index; |
|
345 |
+ |
|
346 |
+ index = $.inArray(this, waypoints[axis]); |
|
347 |
+ return push(stack, index, waypoints[axis]); |
|
348 |
+ }); |
|
349 |
+ return this.pushStack(stack); |
|
350 |
+ }, |
|
351 |
+ _invoke: function(method) { |
|
352 |
+ this.each(function() { |
|
353 |
+ var waypoints; |
|
354 |
+ |
|
355 |
+ waypoints = Waypoint.getWaypointsByElement(this); |
|
356 |
+ return $.each(waypoints, function(i, waypoint) { |
|
357 |
+ waypoint[method](); |
|
358 |
+ return true; |
|
359 |
+ }); |
|
360 |
+ }); |
|
361 |
+ return this; |
|
362 |
+ } |
|
363 |
+ }; |
|
364 |
+ $.fn[wp] = function() { |
|
365 |
+ var args, method; |
|
366 |
+ |
|
367 |
+ method = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : []; |
|
368 |
+ if (methods[method]) { |
|
369 |
+ return methods[method].apply(this, args); |
|
370 |
+ } else if ($.isFunction(method)) { |
|
371 |
+ return methods.init.apply(this, arguments); |
|
372 |
+ } else if ($.isPlainObject(method)) { |
|
373 |
+ return methods.init.apply(this, [null, method]); |
|
374 |
+ } else if (!method) { |
|
375 |
+ return $.error("jQuery Waypoints needs a callback function or handler option."); |
|
376 |
+ } else { |
|
377 |
+ return $.error("The " + method + " method does not exist in jQuery Waypoints."); |
|
378 |
+ } |
|
379 |
+ }; |
|
380 |
+ $.fn[wp].defaults = { |
|
381 |
+ context: window, |
|
382 |
+ continuous: true, |
|
383 |
+ enabled: true, |
|
384 |
+ horizontal: false, |
|
385 |
+ offset: 0, |
|
386 |
+ triggerOnce: false |
|
387 |
+ }; |
|
388 |
+ jQMethods = { |
|
389 |
+ refresh: function() { |
|
390 |
+ return $.each(contexts, function(i, context) { |
|
391 |
+ return context.refresh(); |
|
392 |
+ }); |
|
393 |
+ }, |
|
394 |
+ viewportHeight: function() { |
|
395 |
+ var _ref; |
|
396 |
+ |
|
397 |
+ return (_ref = window.innerHeight) != null ? _ref : $w.height(); |
|
398 |
+ }, |
|
399 |
+ aggregate: function(contextSelector) { |
|
400 |
+ var collection, waypoints, _ref; |
|
401 |
+ |
|
402 |
+ collection = allWaypoints; |
|
403 |
+ if (contextSelector) { |
|
404 |
+ collection = (_ref = contexts[$(contextSelector)[0][contextKey]]) != null ? _ref.waypoints : void 0; |
|
405 |
+ } |
|
406 |
+ if (!collection) { |
|
407 |
+ return []; |
|
408 |
+ } |
|
409 |
+ waypoints = { |
|
410 |
+ horizontal: [], |
|
411 |
+ vertical: [] |
|
412 |
+ }; |
|
413 |
+ $.each(waypoints, function(axis, arr) { |
|
414 |
+ $.each(collection[axis], function(key, waypoint) { |
|
415 |
+ return arr.push(waypoint); |
|
416 |
+ }); |
|
417 |
+ arr.sort(function(a, b) { |
|
418 |
+ return a.offset - b.offset; |
|
419 |
+ }); |
|
420 |
+ waypoints[axis] = $.map(arr, function(waypoint) { |
|
421 |
+ return waypoint.element; |
|
422 |
+ }); |
|
423 |
+ return waypoints[axis] = $.unique(waypoints[axis]); |
|
424 |
+ }); |
|
425 |
+ return waypoints; |
|
426 |
+ }, |
|
427 |
+ above: function(contextSelector) { |
|
428 |
+ if (contextSelector == null) { |
|
429 |
+ contextSelector = window; |
|
430 |
+ } |
|
431 |
+ return jQMethods._filter(contextSelector, 'vertical', function(context, waypoint) { |
|
432 |
+ return waypoint.offset <= context.oldScroll.y; |
|
433 |
+ }); |
|
434 |
+ }, |
|
435 |
+ below: function(contextSelector) { |
|
436 |
+ if (contextSelector == null) { |
|
437 |
+ contextSelector = window; |
|
438 |
+ } |
|
439 |
+ return jQMethods._filter(contextSelector, 'vertical', function(context, waypoint) { |
|
440 |
+ return waypoint.offset > context.oldScroll.y; |
|
441 |
+ }); |
|
442 |
+ }, |
|
443 |
+ left: function(contextSelector) { |
|
444 |
+ if (contextSelector == null) { |
|
445 |
+ contextSelector = window; |
|
446 |
+ } |
|
447 |
+ return jQMethods._filter(contextSelector, 'horizontal', function(context, waypoint) { |
|
448 |
+ return waypoint.offset <= context.oldScroll.x; |
|
449 |
+ }); |
|
450 |
+ }, |
|
451 |
+ right: function(contextSelector) { |
|
452 |
+ if (contextSelector == null) { |
|
453 |
+ contextSelector = window; |
|
454 |
+ } |
|
455 |
+ return jQMethods._filter(contextSelector, 'horizontal', function(context, waypoint) { |
|
456 |
+ return waypoint.offset > context.oldScroll.x; |
|
457 |
+ }); |
|
458 |
+ }, |
|
459 |
+ enable: function() { |
|
460 |
+ return jQMethods._invoke('enable'); |
|
461 |
+ }, |
|
462 |
+ disable: function() { |
|
463 |
+ return jQMethods._invoke('disable'); |
|
464 |
+ }, |
|
465 |
+ destroy: function() { |
|
466 |
+ return jQMethods._invoke('destroy'); |
|
467 |
+ }, |
|
468 |
+ extendFn: function(methodName, f) { |
|
469 |
+ return methods[methodName] = f; |
|
470 |
+ }, |
|
471 |
+ _invoke: function(method) { |
|
472 |
+ var waypoints; |
|
473 |
+ |
|
474 |
+ waypoints = $.extend({}, allWaypoints.vertical, allWaypoints.horizontal); |
|
475 |
+ return $.each(waypoints, function(key, waypoint) { |
|
476 |
+ waypoint[method](); |
|
477 |
+ return true; |
|
478 |
+ }); |
|
479 |
+ }, |
|
480 |
+ _filter: function(selector, axis, test) { |
|
481 |
+ var context, waypoints; |
|
482 |
+ |
|
483 |
+ context = contexts[$(selector)[0][contextKey]]; |
|
484 |
+ if (!context) { |
|
485 |
+ return []; |
|
486 |
+ } |
|
487 |
+ waypoints = []; |
|
488 |
+ $.each(context.waypoints[axis], function(i, waypoint) { |
|
489 |
+ if (test(context, waypoint)) { |
|
490 |
+ return waypoints.push(waypoint); |
|
491 |
+ } |
|
492 |
+ }); |
|
493 |
+ waypoints.sort(function(a, b) { |
|
494 |
+ return a.offset - b.offset; |
|
495 |
+ }); |
|
496 |
+ return $.map(waypoints, function(waypoint) { |
|
497 |
+ return waypoint.element; |
|
498 |
+ }); |
|
499 |
+ } |
|
500 |
+ }; |
|
501 |
+ $[wps] = function() { |
|
502 |
+ var args, method; |
|
503 |
+ |
|
504 |
+ method = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : []; |
|
505 |
+ if (jQMethods[method]) { |
|
506 |
+ return jQMethods[method].apply(null, args); |
|
507 |
+ } else { |
|
508 |
+ return jQMethods.aggregate.call(null, method); |
|
509 |
+ } |
|
510 |
+ }; |
|
511 |
+ $[wps].settings = { |
|
512 |
+ resizeThrottle: 100, |
|
513 |
+ scrollThrottle: 30 |
|
514 |
+ }; |
|
515 |
+ return $w.load(function() { |
|
516 |
+ return $[wps]('refresh'); |
|
517 |
+ }); |
|
518 |
+ }); |
|
519 |
+ |
|
520 |
+}).call(this); |
0 | 521 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,8 @@ |
1 |
+// Generated by CoffeeScript 1.6.2 |
|
2 |
+/* |
|
3 |
+jQuery Waypoints - v2.0.4 |
|
4 |
+Copyright (c) 2011-2014 Caleb Troughton |
|
5 |
+Dual licensed under the MIT license and GPL license. |
|
6 |
+https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt |
|
7 |
+*/ |
|
8 |
+(function(){var t=[].indexOf||function(t){for(var e=0,n=this.length;e<n;e++){if(e in this&&this[e]===t)return e}return-1},e=[].slice;(function(t,e){if(typeof define==="function"&&define.amd){return define("waypoints",["jquery"],function(n){return e(n,t)})}else{return e(t.jQuery,t)}})(this,function(n,r){var i,o,l,s,f,u,c,a,h,d,p,y,v,w,g,m;i=n(r);a=t.call(r,"ontouchstart")>=0;s={horizontal:{},vertical:{}};f=1;c={};u="waypoints-context-id";p="resize.waypoints";y="scroll.waypoints";v=1;w="waypoints-waypoint-ids";g="waypoint";m="waypoints";o=function(){function t(t){var e=this;this.$element=t;this.element=t[0];this.didResize=false;this.didScroll=false;this.id="context"+f++;this.oldScroll={x:t.scrollLeft(),y:t.scrollTop()};this.waypoints={horizontal:{},vertical:{}};this.element[u]=this.id;c[this.id]=this;t.bind(y,function(){var t;if(!(e.didScroll||a)){e.didScroll=true;t=function(){e.doScroll();return e.didScroll=false};return r.setTimeout(t,n[m].settings.scrollThrottle)}});t.bind(p,function(){var t;if(!e.didResize){e.didResize=true;t=function(){n[m]("refresh");return e.didResize=false};return r.setTimeout(t,n[m].settings.resizeThrottle)}})}t.prototype.doScroll=function(){var t,e=this;t={horizontal:{newScroll:this.$element.scrollLeft(),oldScroll:this.oldScroll.x,forward:"right",backward:"left"},vertical:{newScroll:this.$element.scrollTop(),oldScroll:this.oldScroll.y,forward:"down",backward:"up"}};if(a&&(!t.vertical.oldScroll||!t.vertical.newScroll)){n[m]("refresh")}n.each(t,function(t,r){var i,o,l;l=[];o=r.newScroll>r.oldScroll;i=o?r.forward:r.backward;n.each(e.waypoints[t],function(t,e){var n,i;if(r.oldScroll<(n=e.offset)&&n<=r.newScroll){return l.push(e)}else if(r.newScroll<(i=e.offset)&&i<=r.oldScroll){return l.push(e)}});l.sort(function(t,e){return t.offset-e.offset});if(!o){l.reverse()}return n.each(l,function(t,e){if(e.options.continuous||t===l.length-1){return e.trigger([i])}})});return this.oldScroll={x:t.horizontal.newScroll,y:t.vertical.newScroll}};t.prototype.refresh=function(){var t,e,r,i=this;r=n.isWindow(this.element);e=this.$element.offset();this.doScroll();t={horizontal:{contextOffset:r?0:e.left,contextScroll:r?0:this.oldScroll.x,contextDimension:this.$element.width(),oldScroll:this.oldScroll.x,forward:"right",backward:"left",offsetProp:"left"},vertical:{contextOffset:r?0:e.top,contextScroll:r?0:this.oldScroll.y,contextDimension:r?n[m]("viewportHeight"):this.$element.height(),oldScroll:this.oldScroll.y,forward:"down",backward:"up",offsetProp:"top"}};return n.each(t,function(t,e){return n.each(i.waypoints[t],function(t,r){var i,o,l,s,f;i=r.options.offset;l=r.offset;o=n.isWindow(r.element)?0:r.$element.offset()[e.offsetProp];if(n.isFunction(i)){i=i.apply(r.element)}else if(typeof i==="string"){i=parseFloat(i);if(r.options.offset.indexOf("%")>-1){i=Math.ceil(e.contextDimension*i/100)}}r.offset=o-e.contextOffset+e.contextScroll-i;if(r.options.onlyOnScroll&&l!=null||!r.enabled){return}if(l!==null&&l<(s=e.oldScroll)&&s<=r.offset){return r.trigger([e.backward])}else if(l!==null&&l>(f=e.oldScroll)&&f>=r.offset){return r.trigger([e.forward])}else if(l===null&&e.oldScroll>=r.offset){return r.trigger([e.forward])}})})};t.prototype.checkEmpty=function(){if(n.isEmptyObject(this.waypoints.horizontal)&&n.isEmptyObject(this.waypoints.vertical)){this.$element.unbind([p,y].join(" "));return delete c[this.id]}};return t}();l=function(){function t(t,e,r){var i,o;r=n.extend({},n.fn[g].defaults,r);if(r.offset==="bottom-in-view"){r.offset=function(){var t;t=n[m]("viewportHeight");if(!n.isWindow(e.element)){t=e.$element.height()}return t-n(this).outerHeight()}}this.$element=t;this.element=t[0];this.axis=r.horizontal?"horizontal":"vertical";this.callback=r.handler;this.context=e;this.enabled=r.enabled;this.id="waypoints"+v++;this.offset=null;this.options=r;e.waypoints[this.axis][this.id]=this;s[this.axis][this.id]=this;i=(o=this.element[w])!=null?o:[];i.push(this.id);this.element[w]=i}t.prototype.trigger=function(t){if(!this.enabled){return}if(this.callback!=null){this.callback.apply(this.element,t)}if(this.options.triggerOnce){return this.destroy()}};t.prototype.disable=function(){return this.enabled=false};t.prototype.enable=function(){this.context.refresh();return this.enabled=true};t.prototype.destroy=function(){delete s[this.axis][this.id];delete this.context.waypoints[this.axis][this.id];return this.context.checkEmpty()};t.getWaypointsByElement=function(t){var e,r;r=t[w];if(!r){return[]}e=n.extend({},s.horizontal,s.vertical);return n.map(r,function(t){return e[t]})};return t}();d={init:function(t,e){var r;if(e==null){e={}}if((r=e.handler)==null){e.handler=t}this.each(function(){var t,r,i,s;t=n(this);i=(s=e.context)!=null?s:n.fn[g].defaults.context;if(!n.isWindow(i)){i=t.closest(i)}i=n(i);r=c[i[0][u]];if(!r){r=new o(i)}return new l(t,r,e)});n[m]("refresh");return this},disable:function(){return d._invoke.call(this,"disable")},enable:function(){return d._invoke.call(this,"enable")},destroy:function(){return d._invoke.call(this,"destroy")},prev:function(t,e){return d._traverse.call(this,t,e,function(t,e,n){if(e>0){return t.push(n[e-1])}})},next:function(t,e){return d._traverse.call(this,t,e,function(t,e,n){if(e<n.length-1){return t.push(n[e+1])}})},_traverse:function(t,e,i){var o,l;if(t==null){t="vertical"}if(e==null){e=r}l=h.aggregate(e);o=[];this.each(function(){var e;e=n.inArray(this,l[t]);return i(o,e,l[t])});return this.pushStack(o)},_invoke:function(t){this.each(function(){var e;e=l.getWaypointsByElement(this);return n.each(e,function(e,n){n[t]();return true})});return this}};n.fn[g]=function(){var t,r;r=arguments[0],t=2<=arguments.length?e.call(arguments,1):[];if(d[r]){return d[r].apply(this,t)}else if(n.isFunction(r)){return d.init.apply(this,arguments)}else if(n.isPlainObject(r)){return d.init.apply(this,[null,r])}else if(!r){return n.error("jQuery Waypoints needs a callback function or handler option.")}else{return n.error("The "+r+" method does not exist in jQuery Waypoints.")}};n.fn[g].defaults={context:r,continuous:true,enabled:true,horizontal:false,offset:0,triggerOnce:false};h={refresh:function(){return n.each(c,function(t,e){return e.refresh()})},viewportHeight:function(){var t;return(t=r.innerHeight)!=null?t:i.height()},aggregate:function(t){var e,r,i;e=s;if(t){e=(i=c[n(t)[0][u]])!=null?i.waypoints:void 0}if(!e){return[]}r={horizontal:[],vertical:[]};n.each(r,function(t,i){n.each(e[t],function(t,e){return i.push(e)});i.sort(function(t,e){return t.offset-e.offset});r[t]=n.map(i,function(t){return t.element});return r[t]=n.unique(r[t])});return r},above:function(t){if(t==null){t=r}return h._filter(t,"vertical",function(t,e){return e.offset<=t.oldScroll.y})},below:function(t){if(t==null){t=r}return h._filter(t,"vertical",function(t,e){return e.offset>t.oldScroll.y})},left:function(t){if(t==null){t=r}return h._filter(t,"horizontal",function(t,e){return e.offset<=t.oldScroll.x})},right:function(t){if(t==null){t=r}return h._filter(t,"horizontal",function(t,e){return e.offset>t.oldScroll.x})},enable:function(){return h._invoke("enable")},disable:function(){return h._invoke("disable")},destroy:function(){return h._invoke("destroy")},extendFn:function(t,e){return d[t]=e},_invoke:function(t){var e;e=n.extend({},s.vertical,s.horizontal);return n.each(e,function(e,n){n[t]();return true})},_filter:function(t,e,r){var i,o;i=c[n(t)[0][u]];if(!i){return[]}o=[];n.each(i.waypoints[e],function(t,e){if(r(i,e)){return o.push(e)}});o.sort(function(t,e){return t.offset-e.offset});return n.map(o,function(t){return t.element})}};n[m]=function(){var t,n;n=arguments[0],t=2<=arguments.length?e.call(arguments,1):[];if(h[n]){return h[n].apply(null,t)}else{return h.aggregate.call(null,n)}};n[m].settings={resizeThrottle:100,scrollThrottle:30};return i.load(function(){return n[m]("refresh")})})}).call(this); |
|
0 | 9 |
\ No newline at end of file |
1 | 10 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,23 @@ |
1 |
+Copyright (c) 2011-2012 Caleb Troughton |
|
2 |
+ |
|
3 |
+----------------------------------------------------------------------- |
|
4 |
+ |
|
5 |
+The MIT License |
|
6 |
+ |
|
7 |
+Permission is hereby granted, free of charge, to any person obtaining a copy |
|
8 |
+of this software and associated documentation files (the "Software"), to deal |
|
9 |
+in the Software without restriction, including without limitation the rights |
|
10 |
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
11 |
+copies of the Software, and to permit persons to whom the Software is |
|
12 |
+furnished to do so, subject to the following conditions: |
|
13 |
+ |
|
14 |
+The above copyright notice and this permission notice shall be included in |
|
15 |
+all copies or substantial portions of the Software. |
|
16 |
+ |
|
17 |
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
18 |
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
19 |
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
20 |
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
21 |
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
22 |
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
23 |
+THE SOFTWARE. |
|
0 | 24 |
\ No newline at end of file |
1 | 25 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,47 @@ |
1 |
+# jQuery Waypoints |
|
2 |
+ |
|
3 |
+Waypoints is a jQuery plugin that makes it easy to execute a function whenever you scroll to an element. |
|
4 |
+ |
|
5 |
+```js |
|
6 |
+$('.thing').waypoint(function() { |
|
7 |
+ alert('You have scrolled to a thing.'); |
|
8 |
+}); |
|
9 |
+``` |
|
10 |
+If you're new to Waypoints, check out the [Get Started](http://imakewebthings.github.com/jquery-waypoints/#get-started) section. |
|
11 |
+ |
|
12 |
+[Read the full documentation](http://imakewebthings.github.com/jquery-waypoints/#docs) for more details on usage and customization. |
|
13 |
+ |
|
14 |
+## Shortcuts |
|
15 |
+ |
|
16 |
+In addition to the normal Waypoints script, extensions exist to make common UI patterns just a little easier to implement: |
|
17 |
+ |
|
18 |
+- [Infinite Scrolling](http://imakewebthings.github.com/jquery-waypoints/shortcuts/infinite-scroll) |
|
19 |
+- [Sticky Elements](http://imakewebthings.github.com/jquery-waypoints/shortcuts/sticky-elements) |
|
20 |
+ |
|
21 |
+## Examples |
|
22 |
+ |
|
23 |
+Waypoints can also be used as a base for your own custom UI patterns. Here are a few examples: |
|
24 |
+ |
|
25 |
+- [Scroll Analytics](http://imakewebthings.github.com/jquery-waypoints/examples/scroll-analytics) |
|
26 |
+- [Dial Controls](http://imakewebthings.github.com/jquery-waypoints/examples/dial-controls) |
|
27 |
+ |
|
28 |
+## AMD Module Loader Support |
|
29 |
+ |
|
30 |
+If you're using an AMD loader like [RequireJS](http://requirejs.org/), Waypoints registers itself as a named module, `'waypoints'`. Shortcut scripts are anonymous modules. |
|
31 |
+ |
|
32 |
+## Development Environment |
|
33 |
+ |
|
34 |
+If you want to contribute to Waypoints, I love pull requests that include changes to the source `coffee` files as well as the compiled JS and minified files. You can set up the same environment by running `make setup` (which just aliases to `npm install`). This will install the version of CoffeeScript and UglifyJS that I'm using. From there, running `make build` will compile and minify all the necessary files. Test coffee files are compiled on the fly, so compile and minify do not apply to those files. |
|
35 |
+ |
|
36 |
+## License |
|
37 |
+ |
|
38 |
+Copyright (c) 2011-2014 Caleb Troughton |
|
39 |
+Licensed under the [MIT license](https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt). |
|
40 |
+ |
|
41 |
+## Support |
|
42 |
+ |
|
43 |
+Unit tests for Waypoints are written with [Jasmine](http://pivotal.github.com/jasmine/) and [jasmine-jquery](https://github.com/velesin/jasmine-jquery). You can [run them here](http://imakewebthings.github.com/jquery-waypoints/test/). If any of the tests fail, please open an issue and include the browser used, operating system, and description of the failed test. |
|
44 |
+ |
|
45 |
+## Donations |
|
46 |
+ |
|
47 |
+[](https://www.gittip.com/imakewebthings/ "Donate weekly to this project using Gittip") |
1 | 4 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,647 @@ |
1 |
+/*! |
|
2 |
+Waypoints - 3.1.1 |
|
3 |
+Copyright © 2011-2015 Caleb Troughton |
|
4 |
+Licensed under the MIT license. |
|
5 |
+https://github.com/imakewebthings/waypoints/blog/master/licenses.txt |
|
6 |
+*/ |
|
7 |
+(function() { |
|
8 |
+ 'use strict' |
|
9 |
+ |
|
10 |
+ var keyCounter = 0 |
|
11 |
+ var allWaypoints = {} |
|
12 |
+ |
|
13 |
+ /* http://imakewebthings.com/waypoints/api/waypoint */ |
|
14 |
+ function Waypoint(options) { |
|
15 |
+ if (!options) { |
|
16 |
+ throw new Error('No options passed to Waypoint constructor') |
|
17 |
+ } |
|
18 |
+ if (!options.element) { |
|
19 |
+ throw new Error('No element option passed to Waypoint constructor') |
|
20 |
+ } |
|
21 |
+ if (!options.handler) { |
|
22 |
+ throw new Error('No handler option passed to Waypoint constructor') |
|
23 |
+ } |
|
24 |
+ |
|
25 |
+ this.key = 'waypoint-' + keyCounter |
|
26 |
+ this.options = Waypoint.Adapter.extend({}, Waypoint.defaults, options) |
|
27 |
+ this.element = this.options.element |
|
28 |
+ this.adapter = new Waypoint.Adapter(this.element) |
|
29 |
+ this.callback = options.handler |
|
30 |
+ this.axis = this.options.horizontal ? 'horizontal' : 'vertical' |
|
31 |
+ this.enabled = this.options.enabled |
|
32 |
+ this.triggerPoint = null |
|
33 |
+ this.group = Waypoint.Group.findOrCreate({ |
|
34 |
+ name: this.options.group, |
|
35 |
+ axis: this.axis |
|
36 |
+ }) |
|
37 |
+ this.context = Waypoint.Context.findOrCreateByElement(this.options.context) |
|
38 |
+ |
|
39 |
+ if (Waypoint.offsetAliases[this.options.offset]) { |
|
40 |
+ this.options.offset = Waypoint.offsetAliases[this.options.offset] |
|
41 |
+ } |
|
42 |
+ this.group.add(this) |
|
43 |
+ this.context.add(this) |
|
44 |
+ allWaypoints[this.key] = this |
|
45 |
+ keyCounter += 1 |
|
46 |
+ } |
|
47 |
+ |
|
48 |
+ /* Private */ |
|
49 |
+ Waypoint.prototype.queueTrigger = function(direction) { |
|
50 |
+ this.group.queueTrigger(this, direction) |
|
51 |
+ } |
|
52 |
+ |
|
53 |
+ /* Private */ |
|
54 |
+ Waypoint.prototype.trigger = function(args) { |
|
55 |
+ if (!this.enabled) { |
|
56 |
+ return |
|
57 |
+ } |
|
58 |
+ if (this.callback) { |
|
59 |
+ this.callback.apply(this, args) |
|
60 |
+ } |
|
61 |
+ } |
|
62 |
+ |
|
63 |
+ /* Public */ |
|
64 |
+ /* http://imakewebthings.com/waypoints/api/destroy */ |
|
65 |
+ Waypoint.prototype.destroy = function() { |
|
66 |
+ this.context.remove(this) |
|
67 |
+ this.group.remove(this) |
|
68 |
+ delete allWaypoints[this.key] |
|
69 |
+ } |
|
70 |
+ |
|
71 |
+ /* Public */ |
|
72 |
+ /* http://imakewebthings.com/waypoints/api/disable */ |
|
73 |
+ Waypoint.prototype.disable = function() { |
|
74 |
+ this.enabled = false |
|
75 |
+ return this |
|
76 |
+ } |
|
77 |
+ |
|
78 |
+ /* Public */ |
|
79 |
+ /* http://imakewebthings.com/waypoints/api/enable */ |
|
80 |
+ Waypoint.prototype.enable = function() { |
|
81 |
+ this.context.refresh() |
|
82 |
+ this.enabled = true |
|
83 |
+ return this |
|
84 |
+ } |
|
85 |
+ |
|
86 |
+ /* Public */ |
|
87 |
+ /* http://imakewebthings.com/waypoints/api/next */ |
|
88 |
+ Waypoint.prototype.next = function() { |
|
89 |
+ return this.group.next(this) |
|
90 |
+ } |
|
91 |
+ |
|
92 |
+ /* Public */ |
|
93 |
+ /* http://imakewebthings.com/waypoints/api/previous */ |
|
94 |
+ Waypoint.prototype.previous = function() { |
|
95 |
+ return this.group.previous(this) |
|
96 |
+ } |
|
97 |
+ |
|
98 |
+ /* Private */ |
|
99 |
+ Waypoint.invokeAll = function(method) { |
|
100 |
+ var allWaypointsArray = [] |
|
101 |
+ for (var waypointKey in allWaypoints) { |
|
102 |
+ allWaypointsArray.push(allWaypoints[waypointKey]) |
|
103 |
+ } |
|
104 |
+ for (var i = 0, end = allWaypointsArray.length; i < end; i++) { |
|
105 |
+ allWaypointsArray[i][method]() |
|
106 |
+ } |
|
107 |
+ } |
|
108 |
+ |
|
109 |
+ /* Public */ |
|
110 |
+ /* http://imakewebthings.com/waypoints/api/destroy-all */ |
|
111 |
+ Waypoint.destroyAll = function() { |
|
112 |
+ Waypoint.invokeAll('destroy') |
|
113 |
+ } |
|
114 |
+ |
|
115 |
+ /* Public */ |
|
116 |
+ /* http://imakewebthings.com/waypoints/api/disable-all */ |
|
117 |
+ Waypoint.disableAll = function() { |
|
118 |
+ Waypoint.invokeAll('disable') |
|
119 |
+ } |
|
120 |
+ |
|
121 |
+ /* Public */ |
|
122 |
+ /* http://imakewebthings.com/waypoints/api/enable-all */ |
|
123 |
+ Waypoint.enableAll = function() { |
|
124 |
+ Waypoint.invokeAll('enable') |
|
125 |
+ } |
|
126 |
+ |
|
127 |
+ /* Public */ |
|
128 |
+ /* http://imakewebthings.com/waypoints/api/refresh-all */ |
|
129 |
+ Waypoint.refreshAll = function() { |
|
130 |
+ Waypoint.Context.refreshAll() |
|
131 |
+ } |
|
132 |
+ |
|
133 |
+ /* Public */ |
|
134 |
+ /* http://imakewebthings.com/waypoints/api/viewport-height */ |
|
135 |
+ Waypoint.viewportHeight = function() { |
|
136 |
+ return window.innerHeight || document.documentElement.clientHeight |
|
137 |
+ } |
|
138 |
+ |
|
139 |
+ /* Public */ |
|
140 |
+ /* http://imakewebthings.com/waypoints/api/viewport-width */ |
|
141 |
+ Waypoint.viewportWidth = function() { |
|
142 |
+ return document.documentElement.clientWidth |
|
143 |
+ } |
|
144 |
+ |
|
145 |
+ Waypoint.adapters = [] |
|
146 |
+ |
|
147 |
+ Waypoint.defaults = { |
|
148 |
+ context: window, |
|
149 |
+ continuous: true, |
|
150 |
+ enabled: true, |
|
151 |
+ group: 'default', |
|
152 |
+ horizontal: false, |
|
153 |
+ offset: 0 |
|
154 |
+ } |
|
155 |
+ |
|
156 |
+ Waypoint.offsetAliases = { |
|
157 |
+ 'bottom-in-view': function() { |
|
158 |
+ return this.context.innerHeight() - this.adapter.outerHeight() |
|
159 |
+ }, |
|
160 |
+ 'right-in-view': function() { |
|
161 |
+ return this.context.innerWidth() - this.adapter.outerWidth() |
|
162 |
+ } |
|
163 |
+ } |
|
164 |
+ |
|
165 |
+ window.Waypoint = Waypoint |
|
166 |
+}()) |
|
167 |
+;(function() { |
|
168 |
+ 'use strict' |
|
169 |
+ |
|
170 |
+ function requestAnimationFrameShim(callback) { |
|
171 |
+ window.setTimeout(callback, 1000 / 60) |
|
172 |
+ } |
|
173 |
+ |
|
174 |
+ var keyCounter = 0 |
|
175 |
+ var contexts = {} |
|
176 |
+ var Waypoint = window.Waypoint |
|
177 |
+ var oldWindowLoad = window.onload |
|
178 |
+ |
|
179 |
+ /* http://imakewebthings.com/waypoints/api/context */ |
|
180 |
+ function Context(element) { |
|
181 |
+ this.element = element |
|
182 |
+ this.Adapter = Waypoint.Adapter |
|
183 |
+ this.adapter = new this.Adapter(element) |
|
184 |
+ this.key = 'waypoint-context-' + keyCounter |
|
185 |
+ this.didScroll = false |
|
186 |
+ this.didResize = false |
|
187 |
+ this.oldScroll = { |
|
188 |
+ x: this.adapter.scrollLeft(), |
|
189 |
+ y: this.adapter.scrollTop() |
|
190 |
+ } |
|
191 |
+ this.waypoints = { |
|
192 |
+ vertical: {}, |
|
193 |
+ horizontal: {} |
|
194 |
+ } |
|
195 |
+ |
|
196 |
+ element.waypointContextKey = this.key |
|
197 |
+ contexts[element.waypointContextKey] = this |
|
198 |
+ keyCounter += 1 |
|
199 |
+ |
|
200 |
+ this.createThrottledScrollHandler() |
|
201 |
+ this.createThrottledResizeHandler() |
|
202 |
+ } |
|
203 |
+ |
|
204 |
+ /* Private */ |
|
205 |
+ Context.prototype.add = function(waypoint) { |
|
206 |
+ var axis = waypoint.options.horizontal ? 'horizontal' : 'vertical' |
|
207 |
+ this.waypoints[axis][waypoint.key] = waypoint |
|
208 |
+ this.refresh() |
|
209 |
+ } |
|
210 |
+ |
|
211 |
+ /* Private */ |
|
212 |
+ Context.prototype.checkEmpty = function() { |
|
213 |
+ var horizontalEmpty = this.Adapter.isEmptyObject(this.waypoints.horizontal) |
|
214 |
+ var verticalEmpty = this.Adapter.isEmptyObject(this.waypoints.vertical) |
|
215 |
+ if (horizontalEmpty && verticalEmpty) { |
|
216 |
+ this.adapter.off('.waypoints') |
|
217 |
+ delete contexts[this.key] |
|
218 |
+ } |
|
219 |
+ } |
|
220 |
+ |
|
221 |
+ /* Private */ |
|
222 |
+ Context.prototype.createThrottledResizeHandler = function() { |
|
223 |
+ var self = this |
|
224 |
+ |
|
225 |
+ function resizeHandler() { |
|
226 |
+ self.handleResize() |
|
227 |
+ self.didResize = false |
|
228 |
+ } |
|
229 |
+ |
|
230 |
+ this.adapter.on('resize.waypoints', function() { |
|
231 |
+ if (!self.didResize) { |
|
232 |
+ self.didResize = true |
|
233 |
+ Waypoint.requestAnimationFrame(resizeHandler) |
|
234 |
+ } |
|
235 |
+ }) |
|
236 |
+ } |
|
237 |
+ |
|
238 |
+ /* Private */ |
|
239 |
+ Context.prototype.createThrottledScrollHandler = function() { |
|
240 |
+ var self = this |
|
241 |
+ function scrollHandler() { |
|
242 |
+ self.handleScroll() |
|
243 |
+ self.didScroll = false |
|
244 |
+ } |
|
245 |
+ |
|
246 |
+ this.adapter.on('scroll.waypoints', function() { |
|
247 |
+ if (!self.didScroll || Waypoint.isTouch) { |
|
248 |
+ self.didScroll = true |
|
249 |
+ Waypoint.requestAnimationFrame(scrollHandler) |
|
250 |
+ } |
|
251 |
+ }) |
|
252 |
+ } |
|
253 |
+ |
|
254 |
+ /* Private */ |
|
255 |
+ Context.prototype.handleResize = function() { |
|
256 |
+ Waypoint.Context.refreshAll() |
|
257 |
+ } |
|
258 |
+ |
|
259 |
+ /* Private */ |
|
260 |
+ Context.prototype.handleScroll = function() { |
|
261 |
+ var triggeredGroups = {} |
|
262 |
+ var axes = { |
|
263 |
+ horizontal: { |
|
264 |
+ newScroll: this.adapter.scrollLeft(), |
|
265 |
+ oldScroll: this.oldScroll.x, |
|
266 |
+ forward: 'right', |
|
267 |
+ backward: 'left' |
|
268 |
+ }, |
|
269 |
+ vertical: { |
|
270 |
+ newScroll: this.adapter.scrollTop(), |
|
271 |
+ oldScroll: this.oldScroll.y, |
|
272 |
+ forward: 'down', |
|
273 |
+ backward: 'up' |
|
274 |
+ } |
|
275 |
+ } |
|
276 |
+ |
|
277 |
+ for (var axisKey in axes) { |
|
278 |
+ var axis = axes[axisKey] |
|
279 |
+ var isForward = axis.newScroll > axis.oldScroll |
|
280 |
+ var direction = isForward ? axis.forward : axis.backward |
|
281 |
+ |
|
282 |
+ for (var waypointKey in this.waypoints[axisKey]) { |
|
283 |
+ var waypoint = this.waypoints[axisKey][waypointKey] |
|
284 |
+ var wasBeforeTriggerPoint = axis.oldScroll < waypoint.triggerPoint |
|
285 |
+ var nowAfterTriggerPoint = axis.newScroll >= waypoint.triggerPoint |
|
286 |
+ var crossedForward = wasBeforeTriggerPoint && nowAfterTriggerPoint |
|
287 |
+ var crossedBackward = !wasBeforeTriggerPoint && !nowAfterTriggerPoint |
|
288 |
+ if (crossedForward || crossedBackward) { |
|
289 |
+ waypoint.queueTrigger(direction) |
|
290 |
+ triggeredGroups[waypoint.group.id] = waypoint.group |
|
291 |
+ } |
|
292 |
+ } |
|
293 |
+ } |
|
294 |
+ |
|
295 |
+ for (var groupKey in triggeredGroups) { |
|
296 |
+ triggeredGroups[groupKey].flushTriggers() |
|
297 |
+ } |
|
298 |
+ |
|
299 |
+ this.oldScroll = { |
|
300 |
+ x: axes.horizontal.newScroll, |
|
301 |
+ y: axes.vertical.newScroll |
|
302 |
+ } |
|
303 |
+ } |
|
304 |
+ |
|
305 |
+ /* Private */ |
|
306 |
+ Context.prototype.innerHeight = function() { |
|
307 |
+ /*eslint-disable eqeqeq */ |
|
308 |
+ if (this.element == this.element.window) { |
|
309 |
+ return Waypoint.viewportHeight() |
|
310 |
+ } |
|
311 |
+ /*eslint-enable eqeqeq */ |
|
312 |
+ return this.adapter.innerHeight() |
|
313 |
+ } |
|
314 |
+ |
|
315 |
+ /* Private */ |
|
316 |
+ Context.prototype.remove = function(waypoint) { |
|
317 |
+ delete this.waypoints[waypoint.axis][waypoint.key] |
|
318 |
+ this.checkEmpty() |
|
319 |
+ } |
|
320 |
+ |
|
321 |
+ /* Private */ |
|
322 |
+ Context.prototype.innerWidth = function() { |
|
323 |
+ /*eslint-disable eqeqeq */ |
|
324 |
+ if (this.element == this.element.window) { |
|
325 |
+ return Waypoint.viewportWidth() |
|
326 |
+ } |
|
327 |
+ /*eslint-enable eqeqeq */ |
|
328 |
+ return this.adapter.innerWidth() |
|
329 |
+ } |
|
330 |
+ |
|
331 |
+ /* Public */ |
|
332 |
+ /* http://imakewebthings.com/waypoints/api/context-destroy */ |
|
333 |
+ Context.prototype.destroy = function() { |
|
334 |
+ var allWaypoints = [] |
|
335 |
+ for (var axis in this.waypoints) { |
|
336 |
+ for (var waypointKey in this.waypoints[axis]) { |
|
337 |
+ allWaypoints.push(this.waypoints[axis][waypointKey]) |
|
338 |
+ } |
|
339 |
+ } |
|
340 |
+ for (var i = 0, end = allWaypoints.length; i < end; i++) { |
|
341 |
+ allWaypoints[i].destroy() |
|
342 |
+ } |
|
343 |
+ } |
|
344 |
+ |
|
345 |
+ /* Public */ |
|
346 |
+ /* http://imakewebthings.com/waypoints/api/context-refresh */ |
|
347 |
+ Context.prototype.refresh = function() { |
|
348 |
+ /*eslint-disable eqeqeq */ |
|
349 |
+ var isWindow = this.element == this.element.window |
|
350 |
+ /*eslint-enable eqeqeq */ |
|
351 |
+ var contextOffset = this.adapter.offset() |
|
352 |
+ var triggeredGroups = {} |
|
353 |
+ var axes |
|
354 |
+ |
|
355 |
+ this.handleScroll() |
|
356 |
+ axes = { |
|
357 |
+ horizontal: { |
|
358 |
+ contextOffset: isWindow ? 0 : contextOffset.left, |
|
359 |
+ contextScroll: isWindow ? 0 : this.oldScroll.x, |
|
360 |
+ contextDimension: this.innerWidth(), |
|
361 |
+ oldScroll: this.oldScroll.x, |
|
362 |
+ forward: 'right', |
|
363 |
+ backward: 'left', |
|
364 |
+ offsetProp: 'left' |
|
365 |
+ }, |
|
366 |
+ vertical: { |
|
367 |
+ contextOffset: isWindow ? 0 : contextOffset.top, |
|
368 |
+ contextScroll: isWindow ? 0 : this.oldScroll.y, |
|
369 |
+ contextDimension: this.innerHeight(), |
|
370 |
+ oldScroll: this.oldScroll.y, |
|
371 |
+ forward: 'down', |
|
372 |
+ backward: 'up', |
|
373 |
+ offsetProp: 'top' |
|
374 |
+ } |
|
375 |
+ } |
|
376 |
+ |
|
377 |
+ for (var axisKey in axes) { |
|
378 |
+ var axis = axes[axisKey] |
|
379 |
+ for (var waypointKey in this.waypoints[axisKey]) { |
|
380 |
+ var waypoint = this.waypoints[axisKey][waypointKey] |
|
381 |
+ var adjustment = waypoint.options.offset |
|
382 |
+ var oldTriggerPoint = waypoint.triggerPoint |
|
383 |
+ var elementOffset = 0 |
|
384 |
+ var freshWaypoint = oldTriggerPoint == null |
|
385 |
+ var contextModifier, wasBeforeScroll, nowAfterScroll |
|
386 |
+ var triggeredBackward, triggeredForward |
|
387 |
+ |
|
388 |
+ if (waypoint.element !== waypoint.element.window) { |
|
389 |
+ elementOffset = waypoint.adapter.offset()[axis.offsetProp] |
|
390 |
+ } |
|
391 |
+ |
|
392 |
+ if (typeof adjustment === 'function') { |
|
393 |
+ adjustment = adjustment.apply(waypoint) |
|
394 |
+ } |
|
395 |
+ else if (typeof adjustment === 'string') { |
|
396 |
+ adjustment = parseFloat(adjustment) |
|
397 |
+ if (waypoint.options.offset.indexOf('%') > - 1) { |
|
398 |
+ adjustment = Math.ceil(axis.contextDimension * adjustment / 100) |
|
399 |
+ } |
|
400 |
+ } |
|
401 |
+ |
|
402 |
+ contextModifier = axis.contextScroll - axis.contextOffset |
|
403 |
+ waypoint.triggerPoint = elementOffset + contextModifier - adjustment |
|
404 |
+ wasBeforeScroll = oldTriggerPoint < axis.oldScroll |
|
405 |
+ nowAfterScroll = waypoint.triggerPoint >= axis.oldScroll |
|
406 |
+ triggeredBackward = wasBeforeScroll && nowAfterScroll |
|
407 |
+ triggeredForward = !wasBeforeScroll && !nowAfterScroll |
|
408 |
+ |
|
409 |
+ if (!freshWaypoint && triggeredBackward) { |
|
410 |
+ waypoint.queueTrigger(axis.backward) |
|
411 |
+ triggeredGroups[waypoint.group.id] = waypoint.group |
|
412 |
+ } |
|
413 |
+ else if (!freshWaypoint && triggeredForward) { |
|
414 |
+ waypoint.queueTrigger(axis.forward) |
|
415 |
+ triggeredGroups[waypoint.group.id] = waypoint.group |
|
416 |
+ } |
|
417 |
+ else if (freshWaypoint && axis.oldScroll >= waypoint.triggerPoint) { |
|
418 |
+ waypoint.queueTrigger(axis.forward) |
|
419 |
+ triggeredGroups[waypoint.group.id] = waypoint.group |
|
420 |
+ } |
|
421 |
+ } |
|
422 |
+ } |
|
423 |
+ |
|
424 |
+ for (var groupKey in triggeredGroups) { |
|
425 |
+ triggeredGroups[groupKey].flushTriggers() |
|
426 |
+ } |
|
427 |
+ |
|
428 |
+ return this |
|
429 |
+ } |
|
430 |
+ |
|
431 |
+ /* Private */ |
|
432 |
+ Context.findOrCreateByElement = function(element) { |
|
433 |
+ return Context.findByElement(element) || new Context(element) |
|
434 |
+ } |
|
435 |
+ |
|
436 |
+ /* Private */ |
|
437 |
+ Context.refreshAll = function() { |
|
438 |
+ for (var contextId in contexts) { |
|
439 |
+ contexts[contextId].refresh() |
|
440 |
+ } |
|
441 |
+ } |
|
442 |
+ |
|
443 |
+ /* Public */ |
|
444 |
+ /* http://imakewebthings.com/waypoints/api/context-find-by-element */ |
|
445 |
+ Context.findByElement = function(element) { |
|
446 |
+ return contexts[element.waypointContextKey] |
|
447 |
+ } |
|
448 |
+ |
|
449 |
+ window.onload = function() { |
|
450 |
+ if (oldWindowLoad) { |
|
451 |
+ oldWindowLoad() |
|
452 |
+ } |
|
453 |
+ Context.refreshAll() |
|
454 |
+ } |
|
455 |
+ |
|
456 |
+ Waypoint.requestAnimationFrame = function(callback) { |
|
457 |
+ var requestFn = window.requestAnimationFrame || |
|
458 |
+ window.mozRequestAnimationFrame || |
|
459 |
+ window.webkitRequestAnimationFrame || |
|
460 |
+ requestAnimationFrameShim |
|
461 |
+ requestFn.call(window, callback) |
|
462 |
+ } |
|
463 |
+ Waypoint.Context = Context |
|
464 |
+}()) |
|
465 |
+;(function() { |
|
466 |
+ 'use strict' |
|
467 |
+ |
|
468 |
+ function byTriggerPoint(a, b) { |
|
469 |
+ return a.triggerPoint - b.triggerPoint |
|
470 |
+ } |
|
471 |
+ |
|
472 |
+ function byReverseTriggerPoint(a, b) { |
|
473 |
+ return b.triggerPoint - a.triggerPoint |
|
474 |
+ } |
|
475 |
+ |
|
476 |
+ var groups = { |
|
477 |
+ vertical: {}, |
|
478 |
+ horizontal: {} |
|
479 |
+ } |
|
480 |
+ var Waypoint = window.Waypoint |
|
481 |
+ |
|
482 |
+ /* http://imakewebthings.com/waypoints/api/group */ |
|
483 |
+ function Group(options) { |
|
484 |
+ this.name = options.name |
|
485 |
+ this.axis = options.axis |
|
486 |
+ this.id = this.name + '-' + this.axis |
|
487 |
+ this.waypoints = [] |
|
488 |
+ this.clearTriggerQueues() |
|
489 |
+ groups[this.axis][this.name] = this |
|
490 |
+ } |
|
491 |
+ |
|
492 |
+ /* Private */ |
|
493 |
+ Group.prototype.add = function(waypoint) { |
|
494 |
+ this.waypoints.push(waypoint) |
|
495 |
+ } |
|
496 |
+ |
|
497 |
+ /* Private */ |
|
498 |
+ Group.prototype.clearTriggerQueues = function() { |
|
499 |
+ this.triggerQueues = { |
|
500 |
+ up: [], |
|
501 |
+ down: [], |
|
502 |
+ left: [], |
|
503 |
+ right: [] |
|
504 |
+ } |
|
505 |
+ } |
|
506 |
+ |
|
507 |
+ /* Private */ |
|
508 |
+ Group.prototype.flushTriggers = function() { |
|
509 |
+ for (var direction in this.triggerQueues) { |
|
510 |
+ var waypoints = this.triggerQueues[direction] |
|
511 |
+ var reverse = direction === 'up' || direction === 'left' |
|
512 |
+ waypoints.sort(reverse ? byReverseTriggerPoint : byTriggerPoint) |
|
513 |
+ for (var i = 0, end = waypoints.length; i < end; i += 1) { |
|
514 |
+ var waypoint = waypoints[i] |
|
515 |
+ if (waypoint.options.continuous || i === waypoints.length - 1) { |
|
516 |
+ waypoint.trigger([direction]) |
|
517 |
+ } |
|
518 |
+ } |
|
519 |
+ } |
|
520 |
+ this.clearTriggerQueues() |
|
521 |
+ } |
|
522 |
+ |
|
523 |
+ /* Private */ |
|
524 |
+ Group.prototype.next = function(waypoint) { |
|
525 |
+ this.waypoints.sort(byTriggerPoint) |
|
526 |
+ var index = Waypoint.Adapter.inArray(waypoint, this.waypoints) |
|
527 |
+ var isLast = index === this.waypoints.length - 1 |
|
528 |
+ return isLast ? null : this.waypoints[index + 1] |
|
529 |
+ } |
|
530 |
+ |
|
531 |
+ /* Private */ |
|
532 |
+ Group.prototype.previous = function(waypoint) { |
|
533 |
+ this.waypoints.sort(byTriggerPoint) |
|
534 |
+ var index = Waypoint.Adapter.inArray(waypoint, this.waypoints) |
|
535 |
+ return index ? this.waypoints[index - 1] : null |
|
536 |
+ } |
|
537 |
+ |
|
538 |
+ /* Private */ |
|
539 |
+ Group.prototype.queueTrigger = function(waypoint, direction) { |
|
540 |
+ this.triggerQueues[direction].push(waypoint) |
|
541 |
+ } |
|
542 |
+ |
|
543 |
+ /* Private */ |
|
544 |
+ Group.prototype.remove = function(waypoint) { |
|
545 |
+ var index = Waypoint.Adapter.inArray(waypoint, this.waypoints) |
|
546 |
+ if (index > -1) { |
|
547 |
+ this.waypoints.splice(index, 1) |
|
548 |
+ } |
|
549 |
+ } |
|
550 |
+ |
|
551 |
+ /* Public */ |
|
552 |
+ /* http://imakewebthings.com/waypoints/api/first */ |
|
553 |
+ Group.prototype.first = function() { |
|
554 |
+ return this.waypoints[0] |
|
555 |
+ } |
|
556 |
+ |
|
557 |
+ /* Public */ |
|
558 |
+ /* http://imakewebthings.com/waypoints/api/last */ |
|
559 |
+ Group.prototype.last = function() { |
|
560 |
+ return this.waypoints[this.waypoints.length - 1] |
|
561 |
+ } |
|
562 |
+ |
|
563 |
+ /* Private */ |
|
564 |
+ Group.findOrCreate = function(options) { |
|
565 |
+ return groups[options.axis][options.name] || new Group(options) |
|
566 |
+ } |
|
567 |
+ |
|
568 |
+ Waypoint.Group = Group |
|
569 |
+}()) |
|
570 |
+;(function() { |
|
571 |
+ 'use strict' |
|
572 |
+ |
|
573 |
+ var $ = window.jQuery |
|
574 |
+ var Waypoint = window.Waypoint |
|
575 |
+ |
|
576 |
+ function JQueryAdapter(element) { |
|
577 |
+ this.$element = $(element) |
|
578 |
+ } |
|
579 |
+ |
|
580 |
+ $.each([ |
|
581 |
+ 'innerHeight', |
|
582 |
+ 'innerWidth', |
|
583 |
+ 'off', |
|
584 |
+ 'offset', |
|
585 |
+ 'on', |
|
586 |
+ 'outerHeight', |
|
587 |
+ 'outerWidth', |
|
588 |
+ 'scrollLeft', |
|
589 |
+ 'scrollTop' |
|
590 |
+ ], function(i, method) { |
|
591 |
+ JQueryAdapter.prototype[method] = function() { |
|
592 |
+ var args = Array.prototype.slice.call(arguments) |
|
593 |
+ return this.$element[method].apply(this.$element, args) |
|
594 |
+ } |
|
595 |
+ }) |
|
596 |
+ |
|
597 |
+ $.each([ |
|
598 |
+ 'extend', |
|
599 |
+ 'inArray', |
|
600 |
+ 'isEmptyObject' |
|
601 |
+ ], function(i, method) { |
|
602 |
+ JQueryAdapter[method] = $[method] |
|
603 |
+ }) |
|
604 |
+ |
|
605 |
+ Waypoint.adapters.push({ |
|
606 |
+ name: 'jquery', |
|
607 |
+ Adapter: JQueryAdapter |
|
608 |
+ }) |
|
609 |
+ Waypoint.Adapter = JQueryAdapter |
|
610 |
+}()) |
|
611 |
+;(function() { |
|
612 |
+ 'use strict' |
|
613 |
+ |
|
614 |
+ var Waypoint = window.Waypoint |
|
615 |
+ |
|
616 |
+ function createExtension(framework) { |
|
617 |
+ return function() { |
|
618 |
+ var waypoints = [] |
|
619 |
+ var overrides = arguments[0] |
|
620 |
+ |
|
621 |
+ if (framework.isFunction(arguments[0])) { |
|
622 |
+ overrides = framework.extend({}, arguments[1]) |
|
623 |
+ overrides.handler = arguments[0] |
|
624 |
+ } |
|
625 |
+ |
|
626 |
+ this.each(function() { |
|
627 |
+ var options = framework.extend({}, overrides, { |
|
628 |
+ element: this |
|
629 |
+ }) |
|
630 |
+ if (typeof options.context === 'string') { |
|
631 |
+ options.context = framework(this).closest(options.context)[0] |
|
632 |
+ } |
|
633 |
+ waypoints.push(new Waypoint(options)) |
|
634 |
+ }) |
|
635 |
+ |
|
636 |
+ return waypoints |
|
637 |
+ } |
|
638 |
+ } |
|
639 |
+ |
|
640 |
+ if (window.jQuery) { |
|
641 |
+ window.jQuery.fn.waypoint = createExtension(window.jQuery) |
|
642 |
+ } |
|
643 |
+ if (window.Zepto) { |
|
644 |
+ window.Zepto.fn.waypoint = createExtension(window.Zepto) |
|
645 |
+ } |
|
646 |
+}()) |
|
647 |
+; |
|
0 | 648 |
\ No newline at end of file |
1 | 649 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,7 @@ |
1 |
+/*! |
|
2 |
+Waypoints - 3.1.1 |
|
3 |
+Copyright © 2011-2015 Caleb Troughton |
|
4 |
+Licensed under the MIT license. |
|
5 |
+https://github.com/imakewebthings/waypoints/blog/master/licenses.txt |
|
6 |
+*/ |
|
7 |
+!function(){"use strict";function t(o){if(!o)throw new Error("No options passed to Waypoint constructor");if(!o.element)throw new Error("No element option passed to Waypoint constructor");if(!o.handler)throw new Error("No handler option passed to Waypoint constructor");this.key="waypoint-"+e,this.options=t.Adapter.extend({},t.defaults,o),this.element=this.options.element,this.adapter=new t.Adapter(this.element),this.callback=o.handler,this.axis=this.options.horizontal?"horizontal":"vertical",this.enabled=this.options.enabled,this.triggerPoint=null,this.group=t.Group.findOrCreate({name:this.options.group,axis:this.axis}),this.context=t.Context.findOrCreateByElement(this.options.context),t.offsetAliases[this.options.offset]&&(this.options.offset=t.offsetAliases[this.options.offset]),this.group.add(this),this.context.add(this),i[this.key]=this,e+=1}var e=0,i={};t.prototype.queueTrigger=function(t){this.group.queueTrigger(this,t)},t.prototype.trigger=function(t){this.enabled&&this.callback&&this.callback.apply(this,t)},t.prototype.destroy=function(){this.context.remove(this),this.group.remove(this),delete i[this.key]},t.prototype.disable=function(){return this.enabled=!1,this},t.prototype.enable=function(){return this.context.refresh(),this.enabled=!0,this},t.prototype.next=function(){return this.group.next(this)},t.prototype.previous=function(){return this.group.previous(this)},t.invokeAll=function(t){var e=[];for(var o in i)e.push(i[o]);for(var n=0,r=e.length;r>n;n++)e[n][t]()},t.destroyAll=function(){t.invokeAll("destroy")},t.disableAll=function(){t.invokeAll("disable")},t.enableAll=function(){t.invokeAll("enable")},t.refreshAll=function(){t.Context.refreshAll()},t.viewportHeight=function(){return window.innerHeight||document.documentElement.clientHeight},t.viewportWidth=function(){return document.documentElement.clientWidth},t.adapters=[],t.defaults={context:window,continuous:!0,enabled:!0,group:"default",horizontal:!1,offset:0},t.offsetAliases={"bottom-in-view":function(){return this.context.innerHeight()-this.adapter.outerHeight()},"right-in-view":function(){return this.context.innerWidth()-this.adapter.outerWidth()}},window.Waypoint=t}(),function(){"use strict";function t(t){window.setTimeout(t,1e3/60)}function e(t){this.element=t,this.Adapter=n.Adapter,this.adapter=new this.Adapter(t),this.key="waypoint-context-"+i,this.didScroll=!1,this.didResize=!1,this.oldScroll={x:this.adapter.scrollLeft(),y:this.adapter.scrollTop()},this.waypoints={vertical:{},horizontal:{}},t.waypointContextKey=this.key,o[t.waypointContextKey]=this,i+=1,this.createThrottledScrollHandler(),this.createThrottledResizeHandler()}var i=0,o={},n=window.Waypoint,r=window.onload;e.prototype.add=function(t){var e=t.options.horizontal?"horizontal":"vertical";this.waypoints[e][t.key]=t,this.refresh()},e.prototype.checkEmpty=function(){var t=this.Adapter.isEmptyObject(this.waypoints.horizontal),e=this.Adapter.isEmptyObject(this.waypoints.vertical);t&&e&&(this.adapter.off(".waypoints"),delete o[this.key])},e.prototype.createThrottledResizeHandler=function(){function t(){e.handleResize(),e.didResize=!1}var e=this;this.adapter.on("resize.waypoints",function(){e.didResize||(e.didResize=!0,n.requestAnimationFrame(t))})},e.prototype.createThrottledScrollHandler=function(){function t(){e.handleScroll(),e.didScroll=!1}var e=this;this.adapter.on("scroll.waypoints",function(){(!e.didScroll||n.isTouch)&&(e.didScroll=!0,n.requestAnimationFrame(t))})},e.prototype.handleResize=function(){n.Context.refreshAll()},e.prototype.handleScroll=function(){var t={},e={horizontal:{newScroll:this.adapter.scrollLeft(),oldScroll:this.oldScroll.x,forward:"right",backward:"left"},vertical:{newScroll:this.adapter.scrollTop(),oldScroll:this.oldScroll.y,forward:"down",backward:"up"}};for(var i in e){var o=e[i],n=o.newScroll>o.oldScroll,r=n?o.forward:o.backward;for(var s in this.waypoints[i]){var a=this.waypoints[i][s],l=o.oldScroll<a.triggerPoint,h=o.newScroll>=a.triggerPoint,p=l&&h,u=!l&&!h;(p||u)&&(a.queueTrigger(r),t[a.group.id]=a.group)}}for(var c in t)t[c].flushTriggers();this.oldScroll={x:e.horizontal.newScroll,y:e.vertical.newScroll}},e.prototype.innerHeight=function(){return this.element==this.element.window?n.viewportHeight():this.adapter.innerHeight()},e.prototype.remove=function(t){delete this.waypoints[t.axis][t.key],this.checkEmpty()},e.prototype.innerWidth=function(){return this.element==this.element.window?n.viewportWidth():this.adapter.innerWidth()},e.prototype.destroy=function(){var t=[];for(var e in this.waypoints)for(var i in this.waypoints[e])t.push(this.waypoints[e][i]);for(var o=0,n=t.length;n>o;o++)t[o].destroy()},e.prototype.refresh=function(){var t,e=this.element==this.element.window,i=this.adapter.offset(),o={};this.handleScroll(),t={horizontal:{contextOffset:e?0:i.left,contextScroll:e?0:this.oldScroll.x,contextDimension:this.innerWidth(),oldScroll:this.oldScroll.x,forward:"right",backward:"left",offsetProp:"left"},vertical:{contextOffset:e?0:i.top,contextScroll:e?0:this.oldScroll.y,contextDimension:this.innerHeight(),oldScroll:this.oldScroll.y,forward:"down",backward:"up",offsetProp:"top"}};for(var n in t){var r=t[n];for(var s in this.waypoints[n]){var a,l,h,p,u,c=this.waypoints[n][s],d=c.options.offset,f=c.triggerPoint,w=0,y=null==f;c.element!==c.element.window&&(w=c.adapter.offset()[r.offsetProp]),"function"==typeof d?d=d.apply(c):"string"==typeof d&&(d=parseFloat(d),c.options.offset.indexOf("%")>-1&&(d=Math.ceil(r.contextDimension*d/100))),a=r.contextScroll-r.contextOffset,c.triggerPoint=w+a-d,l=f<r.oldScroll,h=c.triggerPoint>=r.oldScroll,p=l&&h,u=!l&&!h,!y&&p?(c.queueTrigger(r.backward),o[c.group.id]=c.group):!y&&u?(c.queueTrigger(r.forward),o[c.group.id]=c.group):y&&r.oldScroll>=c.triggerPoint&&(c.queueTrigger(r.forward),o[c.group.id]=c.group)}}for(var g in o)o[g].flushTriggers();return this},e.findOrCreateByElement=function(t){return e.findByElement(t)||new e(t)},e.refreshAll=function(){for(var t in o)o[t].refresh()},e.findByElement=function(t){return o[t.waypointContextKey]},window.onload=function(){r&&r(),e.refreshAll()},n.requestAnimationFrame=function(e){var i=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||t;i.call(window,e)},n.Context=e}(),function(){"use strict";function t(t,e){return t.triggerPoint-e.triggerPoint}function e(t,e){return e.triggerPoint-t.triggerPoint}function i(t){this.name=t.name,this.axis=t.axis,this.id=this.name+"-"+this.axis,this.waypoints=[],this.clearTriggerQueues(),o[this.axis][this.name]=this}var o={vertical:{},horizontal:{}},n=window.Waypoint;i.prototype.add=function(t){this.waypoints.push(t)},i.prototype.clearTriggerQueues=function(){this.triggerQueues={up:[],down:[],left:[],right:[]}},i.prototype.flushTriggers=function(){for(var i in this.triggerQueues){var o=this.triggerQueues[i],n="up"===i||"left"===i;o.sort(n?e:t);for(var r=0,s=o.length;s>r;r+=1){var a=o[r];(a.options.continuous||r===o.length-1)&&a.trigger([i])}}this.clearTriggerQueues()},i.prototype.next=function(e){this.waypoints.sort(t);var i=n.Adapter.inArray(e,this.waypoints),o=i===this.waypoints.length-1;return o?null:this.waypoints[i+1]},i.prototype.previous=function(e){this.waypoints.sort(t);var i=n.Adapter.inArray(e,this.waypoints);return i?this.waypoints[i-1]:null},i.prototype.queueTrigger=function(t,e){this.triggerQueues[e].push(t)},i.prototype.remove=function(t){var e=n.Adapter.inArray(t,this.waypoints);e>-1&&this.waypoints.splice(e,1)},i.prototype.first=function(){return this.waypoints[0]},i.prototype.last=function(){return this.waypoints[this.waypoints.length-1]},i.findOrCreate=function(t){return o[t.axis][t.name]||new i(t)},n.Group=i}(),function(){"use strict";function t(t){this.$element=e(t)}var e=window.jQuery,i=window.Waypoint;e.each(["innerHeight","innerWidth","off","offset","on","outerHeight","outerWidth","scrollLeft","scrollTop"],function(e,i){t.prototype[i]=function(){var t=Array.prototype.slice.call(arguments);return this.$element[i].apply(this.$element,t)}}),e.each(["extend","inArray","isEmptyObject"],function(i,o){t[o]=e[o]}),i.adapters.push({name:"jquery",Adapter:t}),i.Adapter=t}(),function(){"use strict";function t(t){return function(){var i=[],o=arguments[0];return t.isFunction(arguments[0])&&(o=t.extend({},arguments[1]),o.handler=arguments[0]),this.each(function(){var n=t.extend({},o,{element:this});"string"==typeof n.context&&(n.context=t(this).closest(n.context)[0]),i.push(new e(n))}),i}}var e=window.Waypoint;window.jQuery&&(window.jQuery.fn.waypoint=t(window.jQuery)),window.Zepto&&(window.Zepto.fn.waypoint=t(window.Zepto))}(); |
|
0 | 8 |
\ No newline at end of file |
1 | 9 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,84 @@ |
1 |
+/*! |
|
2 |
+Waypoints Infinite Scroll Shortcut - 3.1.1 |
|
3 |
+Copyright © 2011-2015 Caleb Troughton |
|
4 |
+Licensed under the MIT license. |
|
5 |
+https://github.com/imakewebthings/waypoints/blog/master/licenses.txt |
|
6 |
+*/ |
|
7 |
+(function() { |
|
8 |
+ 'use strict' |
|
9 |
+ |
|
10 |
+ var $ = window.jQuery |
|
11 |
+ var Waypoint = window.Waypoint |
|
12 |
+ |
|
13 |
+ /* http://imakewebthings.com/waypoints/shortcuts/infinite-scroll */ |
|
14 |
+ function Infinite(options) { |
|
15 |
+ this.options = $.extend({}, Infinite.defaults, options) |
|
16 |
+ this.container = this.options.element |
|
17 |
+ if (this.options.container !== 'auto') { |
|
18 |
+ this.container = this.options.container |
|
19 |
+ } |
|
20 |
+ this.$container = $(this.container) |
|
21 |
+ this.$more = $(this.options.more) |
|
22 |
+ |
|
23 |
+ if (this.$more.length) { |
|
24 |
+ this.setupHandler() |
|
25 |
+ this.waypoint = new Waypoint(this.options) |
|
26 |
+ } |
|
27 |
+ } |
|
28 |
+ |
|
29 |
+ /* Private */ |
|
30 |
+ Infinite.prototype.setupHandler = function() { |
|
31 |
+ this.options.handler = $.proxy(function() { |
|
32 |
+ this.options.onBeforePageLoad() |
|
33 |
+ this.destroy() |
|
34 |
+ this.$container.addClass(this.options.loadingClass) |
|
35 |
+ |
|
36 |
+ $.get($(this.options.more).attr('href'), $.proxy(function(data) { |
|
37 |
+ var $data = $($.parseHTML(data)) |
|
38 |
+ var $newMore = $data.find(this.options.more) |
|
39 |
+ |
|
40 |
+ var $items = $data.find(this.options.items) |
|
41 |
+ if (!$items.length) { |
|
42 |
+ $items = $data.filter(this.options.items) |
|
43 |
+ } |
|
44 |
+ |
|
45 |
+ this.$container.append($items) |
|
46 |
+ this.$container.removeClass(this.options.loadingClass) |
|
47 |
+ |
|
48 |
+ if (!$newMore.length) { |
|
49 |
+ $newMore = $data.filter(this.options.more) |
|
50 |
+ } |
|
51 |
+ if ($newMore.length) { |
|
52 |
+ this.$more.replaceWith($newMore) |
|
53 |
+ this.$more = $newMore |
|
54 |
+ this.waypoint = new Waypoint(this.options) |
|
55 |
+ } |
|
56 |
+ else { |
|
57 |
+ this.$more.remove() |
|
58 |
+ } |
|
59 |
+ |
|
60 |
+ this.options.onAfterPageLoad() |
|
61 |
+ }, this)) |
|
62 |
+ }, this) |
|
63 |
+ } |
|
64 |
+ |
|
65 |
+ /* Public */ |
|
66 |
+ Infinite.prototype.destroy = function() { |
|
67 |
+ if (this.waypoint) { |
|
68 |
+ this.waypoint.destroy() |
|
69 |
+ } |
|
70 |
+ } |
|
71 |
+ |
|
72 |
+ Infinite.defaults = { |
|
73 |
+ container: 'auto', |
|
74 |
+ items: '.infinite-item', |
|
75 |
+ more: '.infinite-more-link', |
|
76 |
+ offset: 'bottom-in-view', |
|
77 |
+ loadingClass: 'infinite-loading', |
|
78 |
+ onBeforePageLoad: $.noop, |
|
79 |
+ onAfterPageLoad: $.noop |
|
80 |
+ } |
|
81 |
+ |
|
82 |
+ Waypoint.Infinite = Infinite |
|
83 |
+}()) |
|
84 |
+; |
|
0 | 85 |
\ No newline at end of file |
1 | 86 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,7 @@ |
1 |
+/*! |
|
2 |
+Waypoints Infinite Scroll Shortcut - 3.1.1 |
|
3 |
+Copyright © 2011-2015 Caleb Troughton |
|
4 |
+Licensed under the MIT license. |
|
5 |
+https://github.com/imakewebthings/waypoints/blog/master/licenses.txt |
|
6 |
+*/ |
|
7 |
+!function(){"use strict";function t(n){this.options=i.extend({},t.defaults,n),this.container=this.options.element,"auto"!==this.options.container&&(this.container=this.options.container),this.$container=i(this.container),this.$more=i(this.options.more),this.$more.length&&(this.setupHandler(),this.waypoint=new o(this.options))}var i=window.jQuery,o=window.Waypoint;t.prototype.setupHandler=function(){this.options.handler=i.proxy(function(){this.options.onBeforePageLoad(),this.destroy(),this.$container.addClass(this.options.loadingClass),i.get(i(this.options.more).attr("href"),i.proxy(function(t){var n=i(i.parseHTML(t)),e=n.find(this.options.more),s=n.find(this.options.items);s.length||(s=n.filter(this.options.items)),this.$container.append(s),this.$container.removeClass(this.options.loadingClass),e.length||(e=n.filter(this.options.more)),e.length?(this.$more.replaceWith(e),this.$more=e,this.waypoint=new o(this.options)):this.$more.remove(),this.options.onAfterPageLoad()},this))},this)},t.prototype.destroy=function(){this.waypoint&&this.waypoint.destroy()},t.defaults={container:"auto",items:".infinite-item",more:".infinite-more-link",offset:"bottom-in-view",loadingClass:"infinite-loading",onBeforePageLoad:i.noop,onAfterPageLoad:i.noop},o.Infinite=t}(); |
|
0 | 8 |
\ No newline at end of file |
1 | 9 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,103 @@ |
1 |
+/*! |
|
2 |
+Waypoints Inview Shortcut - 3.1.1 |
|
3 |
+Copyright © 2011-2015 Caleb Troughton |
|
4 |
+Licensed under the MIT license. |
|
5 |
+https://github.com/imakewebthings/waypoints/blog/master/licenses.txt |
|
6 |
+*/ |
|
7 |
+(function() { |
|
8 |
+ 'use strict' |
|
9 |
+ |
|
10 |
+ function noop() {} |
|
11 |
+ |
|
12 |
+ var Waypoint = window.Waypoint |
|
13 |
+ |
|
14 |
+ /* http://imakewebthings.com/waypoints/shortcuts/inview */ |
|
15 |
+ function Inview(options) { |
|
16 |
+ this.options = Waypoint.Adapter.extend({}, Inview.defaults, options) |
|
17 |
+ this.axis = this.options.horizontal ? 'horizontal' : 'vertical' |
|
18 |
+ this.waypoints = [] |
|
19 |
+ this.createWaypoints() |
|
20 |
+ } |
|
21 |
+ |
|
22 |
+ /* Private */ |
|
23 |
+ Inview.prototype.createWaypoints = function() { |
|
24 |
+ var configs = { |
|
25 |
+ vertical: [{ |
|
26 |
+ down: 'enter', |
|
27 |
+ up: 'exited', |
|
28 |
+ offset: '100%' |
|
29 |
+ }, { |
|
30 |
+ down: 'entered', |
|
31 |
+ up: 'exit', |
|
32 |
+ offset: 'bottom-in-view' |
|
33 |
+ }, { |
|
34 |
+ down: 'exit', |
|
35 |
+ up: 'entered', |
|
36 |
+ offset: 0 |
|
37 |
+ }, { |
|
38 |
+ down: 'exited', |
|
39 |
+ up: 'enter', |
|
40 |
+ offset: function() { |
|
41 |
+ return -this.adapter.outerHeight() |
|
42 |
+ } |
|
43 |
+ }], |
|
44 |
+ horizontal: [{ |
|
45 |
+ right: 'enter', |
|
46 |
+ left: 'exited', |
|
47 |
+ offset: '100%' |
|
48 |
+ }, { |
|
49 |
+ right: 'entered', |
|
50 |
+ left: 'exit', |
|
51 |
+ offset: 'right-in-view' |
|
52 |
+ }, { |
|
53 |
+ right: 'exit', |
|
54 |
+ left: 'entered', |
|
55 |
+ offset: 0 |
|
56 |
+ }, { |
|
57 |
+ right: 'exited', |
|
58 |
+ left: 'enter', |
|
59 |
+ offset: function() { |
|
60 |
+ return -this.adapter.outerWidth() |
|
61 |
+ } |
|
62 |
+ }] |
|
63 |
+ } |
|
64 |
+ |
|
65 |
+ for (var i = 0, end = configs[this.axis].length; i < end; i++) { |
|
66 |
+ var config = configs[this.axis][i] |
|
67 |
+ this.createWaypoint(config) |
|
68 |
+ } |
|
69 |
+ } |
|
70 |
+ |
|
71 |
+ /* Private */ |
|
72 |
+ Inview.prototype.createWaypoint = function(config) { |
|
73 |
+ var self = this |
|
74 |
+ this.waypoints.push(new Waypoint({ |
|
75 |
+ element: this.options.element, |
|
76 |
+ handler: (function(config) { |
|
77 |
+ return function(direction) { |
|
78 |
+ self.options[config[direction]].call(this, direction) |
|
79 |
+ } |
|
80 |
+ }(config)), |
|
81 |
+ offset: config.offset, |
|
82 |
+ horizontal: this.options.horizontal |
|
83 |
+ })) |
|
84 |
+ } |
|
85 |
+ |
|
86 |
+ /* Public */ |
|
87 |
+ Inview.prototype.destroy = function() { |
|
88 |
+ for (var i = 0, end = this.waypoints.length; i < end; i++) { |
|
89 |
+ this.waypoints[i].destroy() |
|
90 |
+ } |
|
91 |
+ this.waypoints = [] |
|
92 |
+ } |
|
93 |
+ |
|
94 |
+ Inview.defaults = { |
|
95 |
+ enter: noop, |
|
96 |
+ entered: noop, |
|
97 |
+ exit: noop, |
|
98 |
+ exited: noop |
|
99 |
+ } |
|
100 |
+ |
|
101 |
+ Waypoint.Inview = Inview |
|
102 |
+}()) |
|
103 |
+; |
|
0 | 104 |
\ No newline at end of file |
1 | 105 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,7 @@ |
1 |
+/*! |
|
2 |
+Waypoints Inview Shortcut - 3.1.1 |
|
3 |
+Copyright © 2011-2015 Caleb Troughton |
|
4 |
+Licensed under the MIT license. |
|
5 |
+https://github.com/imakewebthings/waypoints/blog/master/licenses.txt |
|
6 |
+*/ |
|
7 |
+!function(){"use strict";function t(){}function e(t){this.options=i.Adapter.extend({},e.defaults,t),this.axis=this.options.horizontal?"horizontal":"vertical",this.waypoints=[],this.createWaypoints()}var i=window.Waypoint;e.prototype.createWaypoints=function(){for(var t={vertical:[{down:"enter",up:"exited",offset:"100%"},{down:"entered",up:"exit",offset:"bottom-in-view"},{down:"exit",up:"entered",offset:0},{down:"exited",up:"enter",offset:function(){return-this.adapter.outerHeight()}}],horizontal:[{right:"enter",left:"exited",offset:"100%"},{right:"entered",left:"exit",offset:"right-in-view"},{right:"exit",left:"entered",offset:0},{right:"exited",left:"enter",offset:function(){return-this.adapter.outerWidth()}}]},e=0,i=t[this.axis].length;i>e;e++){var o=t[this.axis][e];this.createWaypoint(o)}},e.prototype.createWaypoint=function(t){var e=this;this.waypoints.push(new i({element:this.options.element,handler:function(t){return function(i){e.options[t[i]].call(this,i)}}(t),offset:t.offset,horizontal:this.options.horizontal}))},e.prototype.destroy=function(){for(var t=0,e=this.waypoints.length;e>t;t++)this.waypoints[t].destroy();this.waypoints=[]},e.defaults={enter:t,entered:t,exit:t,exited:t},i.Inview=e}(); |
|
0 | 8 |
\ No newline at end of file |
1 | 9 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,65 @@ |
1 |
+/*! |
|
2 |
+Waypoints Sticky Element Shortcut - 3.1.1 |
|
3 |
+Copyright © 2011-2015 Caleb Troughton |
|
4 |
+Licensed under the MIT license. |
|
5 |
+https://github.com/imakewebthings/waypoints/blog/master/licenses.txt |
|
6 |
+*/ |
|
7 |
+(function() { |
|
8 |
+ 'use strict' |
|
9 |
+ |
|
10 |
+ var $ = window.jQuery |
|
11 |
+ var Waypoint = window.Waypoint |
|
12 |
+ |
|
13 |
+ /* http://imakewebthings.com/waypoints/shortcuts/sticky-elements */ |
|
14 |
+ function Sticky(options) { |
|
15 |
+ this.options = $.extend({}, Waypoint.defaults, Sticky.defaults, options) |
|
16 |
+ this.element = this.options.element |
|
17 |
+ this.$element = $(this.element) |
|
18 |
+ this.createWrapper() |
|
19 |
+ this.createWaypoint() |
|
20 |
+ } |
|
21 |
+ |
|
22 |
+ /* Private */ |
|
23 |
+ Sticky.prototype.createWaypoint = function() { |
|
24 |
+ var originalHandler = this.options.handler |
|
25 |
+ |
|
26 |
+ this.waypoint = new Waypoint($.extend({}, this.options, { |
|
27 |
+ element: this.wrapper, |
|
28 |
+ handler: $.proxy(function(direction) { |
|
29 |
+ var shouldBeStuck = this.options.direction.indexOf(direction) > -1 |
|
30 |
+ var wrapperHeight = shouldBeStuck ? this.$element.outerHeight(true) : '' |
|
31 |
+ |
|
32 |
+ this.$wrapper.height(wrapperHeight) |
|
33 |
+ this.$element.toggleClass(this.options.stuckClass, shouldBeStuck) |
|
34 |
+ |
|
35 |
+ if (originalHandler) { |
|
36 |
+ originalHandler.call(this, direction) |
|
37 |
+ } |
|
38 |
+ }, this) |
|
39 |
+ })) |
|
40 |
+ } |
|
41 |
+ |
|
42 |
+ /* Private */ |
|
43 |
+ Sticky.prototype.createWrapper = function() { |
|
44 |
+ this.$element.wrap(this.options.wrapper) |
|
45 |
+ this.$wrapper = this.$element.parent() |
|
46 |
+ this.wrapper = this.$wrapper[0] |
|
47 |
+ } |
|
48 |
+ |
|
49 |
+ /* Public */ |
|
50 |
+ Sticky.prototype.destroy = function() { |
|
51 |
+ if (this.$element.parent()[0] === this.wrapper) { |
|
52 |
+ this.waypoint.destroy() |
|
53 |
+ this.$element.removeClass(this.options.stuckClass).unwrap() |
|
54 |
+ } |
|
55 |
+ } |
|
56 |
+ |
|
57 |
+ Sticky.defaults = { |
|
58 |
+ wrapper: '<div class="sticky-wrapper" />', |
|
59 |
+ stuckClass: 'stuck', |
|
60 |
+ direction: 'down right' |
|
61 |
+ } |
|
62 |
+ |
|
63 |
+ Waypoint.Sticky = Sticky |
|
64 |
+}()) |
|
65 |
+; |
|
0 | 66 |
\ No newline at end of file |
1 | 67 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,7 @@ |
1 |
+/*! |
|
2 |
+Waypoints Sticky Element Shortcut - 3.1.1 |
|
3 |
+Copyright © 2011-2015 Caleb Troughton |
|
4 |
+Licensed under the MIT license. |
|
5 |
+https://github.com/imakewebthings/waypoints/blog/master/licenses.txt |
|
6 |
+*/ |
|
7 |
+!function(){"use strict";function t(s){this.options=e.extend({},i.defaults,t.defaults,s),this.element=this.options.element,this.$element=e(this.element),this.createWrapper(),this.createWaypoint()}var e=window.jQuery,i=window.Waypoint;t.prototype.createWaypoint=function(){var t=this.options.handler;this.waypoint=new i(e.extend({},this.options,{element:this.wrapper,handler:e.proxy(function(e){var i=this.options.direction.indexOf(e)>-1,s=i?this.$element.outerHeight(!0):"";this.$wrapper.height(s),this.$element.toggleClass(this.options.stuckClass,i),t&&t.call(this,e)},this)}))},t.prototype.createWrapper=function(){this.$element.wrap(this.options.wrapper),this.$wrapper=this.$element.parent(),this.wrapper=this.$wrapper[0]},t.prototype.destroy=function(){this.$element.parent()[0]===this.wrapper&&(this.waypoint.destroy(),this.$element.removeClass(this.options.stuckClass).unwrap())},t.defaults={wrapper:'<div class="sticky-wrapper" />',stuckClass:"stuck",direction:"down right"},i.Sticky=t}(); |
|
0 | 8 |
\ No newline at end of file |
1 | 9 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,46 @@ |
1 |
+/*! |
|
2 |
+Waypoints Debug - 3.1.1 |
|
3 |
+Copyright © 2011-2015 Caleb Troughton |
|
4 |
+Licensed under the MIT license. |
|
5 |
+https://github.com/imakewebthings/waypoints/blog/master/licenses.txt |
|
6 |
+*/ |
|
7 |
+(function() { |
|
8 |
+ 'use strict' |
|
9 |
+ |
|
10 |
+ var displayNoneMessage = [ |
|
11 |
+ 'You have a Waypoint element with display none. For more information on ', |
|
12 |
+ 'why this is a bad idea read ', |
|
13 |
+ 'http://imakewebthings.com/waypoints/guides/debugging/#display-none' |
|
14 |
+ ].join('') |
|
15 |
+ var fixedMessage = [ |
|
16 |
+ 'You have a Waypoint element with fixed positioning. For more ', |
|
17 |
+ 'information on why this is a bad idea read ', |
|
18 |
+ 'http://imakewebthings.com/waypoints/guides/debugging/#fixed-position' |
|
19 |
+ ].join('') |
|
20 |
+ |
|
21 |
+ function checkWaypointStyles() { |
|
22 |
+ var originalRefresh = window.Waypoint.Context.prototype.refresh |
|
23 |
+ |
|
24 |
+ window.Waypoint.Context.prototype.refresh = function() { |
|
25 |
+ for (var axis in this.waypoints) { |
|
26 |
+ for (var key in this.waypoints[axis]) { |
|
27 |
+ var waypoint = this.waypoints[axis][key] |
|
28 |
+ var style = window.getComputedStyle(waypoint.element) |
|
29 |
+ if (!waypoint.enabled) { |
|
30 |
+ continue |
|
31 |
+ } |
|
32 |
+ if (style && style.display === 'none') { |
|
33 |
+ console.error(displayNoneMessage) |
|
34 |
+ } |
|
35 |
+ if (style && style.position === 'fixed') { |
|
36 |
+ console.error(fixedMessage) |
|
37 |
+ } |
|
38 |
+ } |
|
39 |
+ } |
|
40 |
+ return originalRefresh.call(this) |
|
41 |
+ } |
|
42 |
+ } |
|
43 |
+ |
|
44 |
+ checkWaypointStyles() |
|
45 |
+}()) |
|
46 |
+; |
|
0 | 47 |
\ No newline at end of file |
1 | 48 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,23 @@ |
1 |
+Copyright (c) 2011-2012 Caleb Troughton |
|
2 |
+ |
|
3 |
+----------------------------------------------------------------------- |
|
4 |
+ |
|
5 |
+The MIT License |
|
6 |
+ |
|
7 |
+Permission is hereby granted, free of charge, to any person obtaining a copy |
|
8 |
+of this software and associated documentation files (the "Software"), to deal |
|
9 |
+in the Software without restriction, including without limitation the rights |
|
10 |
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
11 |
+copies of the Software, and to permit persons to whom the Software is |
|
12 |
+furnished to do so, subject to the following conditions: |
|
13 |
+ |
|
14 |
+The above copyright notice and this permission notice shall be included in |
|
15 |
+all copies or substantial portions of the Software. |
|
16 |
+ |
|
17 |
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
18 |
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
19 |
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
20 |
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
21 |
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
22 |
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
23 |
+THE SOFTWARE. |
|
0 | 24 |
\ No newline at end of file |
... | ... |
@@ -1,4 +1,4 @@ |
1 |
-<script src="system/modules/eSM_waypoints/vendor/waypoints/<?php echo WAYPOINTS; ?>/assets/js/jquery.waypoints.min.js"></script> |
|
1 |
+<script src="system/modules/eSM_waypoints/assets/lib/waypoints/<?php echo WAYPOINTS; ?>/assets/js/jquery.waypoints.min.js"></script> |
|
2 | 2 |
<script> |
3 | 3 |
(function($) { |
4 | 4 |
$(document).ready(function() { |
5 | 5 |
deleted file mode 100644 |
... | ... |
@@ -1,47 +0,0 @@ |
1 |
-# jQuery Waypoints |
|
2 |
- |
|
3 |
-Waypoints is a jQuery plugin that makes it easy to execute a function whenever you scroll to an element. |
|
4 |
- |
|
5 |
-```js |
|
6 |
-$('.thing').waypoint(function() { |
|
7 |
- alert('You have scrolled to a thing.'); |
|
8 |
-}); |
|
9 |
-``` |
|
10 |
-If you're new to Waypoints, check out the [Get Started](http://imakewebthings.github.com/jquery-waypoints/#get-started) section. |
|
11 |
- |
|
12 |
-[Read the full documentation](http://imakewebthings.github.com/jquery-waypoints/#docs) for more details on usage and customization. |
|
13 |
- |
|
14 |
-## Shortcuts |
|
15 |
- |
|
16 |
-In addition to the normal Waypoints script, extensions exist to make common UI patterns just a little easier to implement: |
|
17 |
- |
|
18 |
-- [Infinite Scrolling](http://imakewebthings.github.com/jquery-waypoints/shortcuts/infinite-scroll) |
|
19 |
-- [Sticky Elements](http://imakewebthings.github.com/jquery-waypoints/shortcuts/sticky-elements) |
|
20 |
- |
|
21 |
-## Examples |
|
22 |
- |
|
23 |
-Waypoints can also be used as a base for your own custom UI patterns. Here are a few examples: |
|
24 |
- |
|
25 |
-- [Scroll Analytics](http://imakewebthings.github.com/jquery-waypoints/examples/scroll-analytics) |
|
26 |
-- [Dial Controls](http://imakewebthings.github.com/jquery-waypoints/examples/dial-controls) |
|
27 |
- |
|
28 |
-## AMD Module Loader Support |
|
29 |
- |
|
30 |
-If you're using an AMD loader like [RequireJS](http://requirejs.org/), Waypoints registers itself as a named module, `'waypoints'`. Shortcut scripts are anonymous modules. |
|
31 |
- |
|
32 |
-## Development Environment |
|
33 |
- |
|
34 |
-If you want to contribute to Waypoints, I love pull requests that include changes to the source `coffee` files as well as the compiled JS and minified files. You can set up the same environment by running `make setup` (which just aliases to `npm install`). This will install the version of CoffeeScript and UglifyJS that I'm using. From there, running `make build` will compile and minify all the necessary files. Test coffee files are compiled on the fly, so compile and minify do not apply to those files. |
|
35 |
- |
|
36 |
-## License |
|
37 |
- |
|
38 |
-Copyright (c) 2011-2014 Caleb Troughton |
|
39 |
-Licensed under the [MIT license](https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt). |
|
40 |
- |
|
41 |
-## Support |
|
42 |
- |
|
43 |
-Unit tests for Waypoints are written with [Jasmine](http://pivotal.github.com/jasmine/) and [jasmine-jquery](https://github.com/velesin/jasmine-jquery). You can [run them here](http://imakewebthings.github.com/jquery-waypoints/test/). If any of the tests fail, please open an issue and include the browser used, operating system, and description of the failed test. |
|
44 |
- |
|
45 |
-## Donations |
|
46 |
- |
|
47 |
-[](https://www.gittip.com/imakewebthings/ "Donate weekly to this project using Gittip") |
4 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,520 +0,0 @@ |
1 |
-// Generated by CoffeeScript 1.6.2 |
|
2 |
-/* |
|
3 |
-jQuery Waypoints - v2.0.4 |
|
4 |
-Copyright (c) 2011-2014 Caleb Troughton |
|
5 |
-Dual licensed under the MIT license and GPL license. |
|
6 |
-https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt |
|
7 |
-*/ |
|
8 |
- |
|
9 |
- |
|
10 |
-(function() { |
|
11 |
- var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, |
|
12 |
- __slice = [].slice; |
|
13 |
- |
|
14 |
- (function(root, factory) { |
|
15 |
- if (typeof define === 'function' && define.amd) { |
|
16 |
- return define('waypoints', ['jquery'], function($) { |
|
17 |
- return factory($, root); |
|
18 |
- }); |
|
19 |
- } else { |
|
20 |
- return factory(root.jQuery, root); |
|
21 |
- } |
|
22 |
- })(this, function($, window) { |
|
23 |
- var $w, Context, Waypoint, allWaypoints, contextCounter, contextKey, contexts, isTouch, jQMethods, methods, resizeEvent, scrollEvent, waypointCounter, waypointKey, wp, wps; |
|
24 |
- |
|
25 |
- $w = $(window); |
|
26 |
- isTouch = __indexOf.call(window, 'ontouchstart') >= 0; |
|
27 |
- allWaypoints = { |
|
28 |
- horizontal: {}, |
|
29 |
- vertical: {} |
|
30 |
- }; |
|
31 |
- contextCounter = 1; |
|
32 |
- contexts = {}; |
|
33 |
- contextKey = 'waypoints-context-id'; |
|
34 |
- resizeEvent = 'resize.waypoints'; |
|
35 |
- scrollEvent = 'scroll.waypoints'; |
|
36 |
- waypointCounter = 1; |
|
37 |
- waypointKey = 'waypoints-waypoint-ids'; |
|
38 |
- wp = 'waypoint'; |
|
39 |
- wps = 'waypoints'; |
|
40 |
- Context = (function() { |
|
41 |
- function Context($element) { |
|
42 |
- var _this = this; |
|
43 |
- |
|
44 |
- this.$element = $element; |
|
45 |
- this.element = $element[0]; |
|
46 |
- this.didResize = false; |
|
47 |
- this.didScroll = false; |
|
48 |
- this.id = 'context' + contextCounter++; |
|
49 |
- this.oldScroll = { |
|
50 |
- x: $element.scrollLeft(), |
|
51 |
- y: $element.scrollTop() |
|
52 |
- }; |
|
53 |
- this.waypoints = { |
|
54 |
- horizontal: {}, |
|
55 |
- vertical: {} |
|
56 |
- }; |
|
57 |
- this.element[contextKey] = this.id; |
|
58 |
- contexts[this.id] = this; |
|
59 |
- $element.bind(scrollEvent, function() { |
|
60 |
- var scrollHandler; |
|
61 |
- |
|
62 |
- if (!(_this.didScroll || isTouch)) { |
|
63 |
- _this.didScroll = true; |
|
64 |
- scrollHandler = function() { |
|
65 |
- _this.doScroll(); |
|
66 |
- return _this.didScroll = false; |
|
67 |
- }; |
|
68 |
- return window.setTimeout(scrollHandler, $[wps].settings.scrollThrottle); |
|
69 |
- } |
|
70 |
- }); |
|
71 |
- $element.bind(resizeEvent, function() { |
|
72 |
- var resizeHandler; |
|
73 |
- |
|
74 |
- if (!_this.didResize) { |
|
75 |
- _this.didResize = true; |
|
76 |
- resizeHandler = function() { |
|
77 |
- $[wps]('refresh'); |
|
78 |
- return _this.didResize = false; |
|
79 |
- }; |
|
80 |
- return window.setTimeout(resizeHandler, $[wps].settings.resizeThrottle); |
|
81 |
- } |
|
82 |
- }); |
|
83 |
- } |
|
84 |
- |
|
85 |
- Context.prototype.doScroll = function() { |
|
86 |
- var axes, |
|
87 |
- _this = this; |
|
88 |
- |
|
89 |
- axes = { |
|
90 |
- horizontal: { |
|
91 |
- newScroll: this.$element.scrollLeft(), |
|
92 |
- oldScroll: this.oldScroll.x, |
|
93 |
- forward: 'right', |
|
94 |
- backward: 'left' |
|
95 |
- }, |
|
96 |
- vertical: { |
|
97 |
- newScroll: this.$element.scrollTop(), |
|
98 |
- oldScroll: this.oldScroll.y, |
|
99 |
- forward: 'down', |
|
100 |
- backward: 'up' |
|
101 |
- } |
|
102 |
- }; |
|
103 |
- if (isTouch && (!axes.vertical.oldScroll || !axes.vertical.newScroll)) { |
|
104 |
- $[wps]('refresh'); |
|
105 |
- } |
|
106 |
- $.each(axes, function(aKey, axis) { |
|
107 |
- var direction, isForward, triggered; |
|
108 |
- |
|
109 |
- triggered = []; |
|
110 |
- isForward = axis.newScroll > axis.oldScroll; |
|
111 |
- direction = isForward ? axis.forward : axis.backward; |
|
112 |
- $.each(_this.waypoints[aKey], function(wKey, waypoint) { |
|
113 |
- var _ref, _ref1; |
|
114 |
- |
|
115 |
- if ((axis.oldScroll < (_ref = waypoint.offset) && _ref <= axis.newScroll)) { |
|
116 |
- return triggered.push(waypoint); |
|
117 |
- } else if ((axis.newScroll < (_ref1 = waypoint.offset) && _ref1 <= axis.oldScroll)) { |
|
118 |
- return triggered.push(waypoint); |
|
119 |
- } |
|
120 |
- }); |
|
121 |
- triggered.sort(function(a, b) { |
|
122 |
- return a.offset - b.offset; |
|
123 |
- }); |
|
124 |
- if (!isForward) { |
|
125 |
- triggered.reverse(); |
|
126 |
- } |
|
127 |
- return $.each(triggered, function(i, waypoint) { |
|
128 |
- if (waypoint.options.continuous || i === triggered.length - 1) { |
|
129 |
- return waypoint.trigger([direction]); |
|
130 |
- } |
|
131 |
- }); |
|
132 |
- }); |
|
133 |
- return this.oldScroll = { |
|
134 |
- x: axes.horizontal.newScroll, |
|
135 |
- y: axes.vertical.newScroll |
|
136 |
- }; |
|
137 |
- }; |
|
138 |
- |
|
139 |
- Context.prototype.refresh = function() { |
|
140 |
- var axes, cOffset, isWin, |
|
141 |
- _this = this; |
|
142 |
- |
|
143 |
- isWin = $.isWindow(this.element); |
|
144 |
- cOffset = this.$element.offset(); |
|
145 |
- this.doScroll(); |
|
146 |
- axes = { |
|
147 |
- horizontal: { |
|
148 |
- contextOffset: isWin ? 0 : cOffset.left, |
|
149 |
- contextScroll: isWin ? 0 : this.oldScroll.x, |
|
150 |
- contextDimension: this.$element.width(), |
|
151 |
- oldScroll: this.oldScroll.x, |
|
152 |
- forward: 'right', |
|
153 |
- backward: 'left', |
|
154 |
- offsetProp: 'left' |
|
155 |
- }, |
|
156 |
- vertical: { |
|
157 |
- contextOffset: isWin ? 0 : cOffset.top, |
|
158 |
- contextScroll: isWin ? 0 : this.oldScroll.y, |
|
159 |
- contextDimension: isWin ? $[wps]('viewportHeight') : this.$element.height(), |
|
160 |
- oldScroll: this.oldScroll.y, |
|
161 |
- forward: 'down', |
|
162 |
- backward: 'up', |
|
163 |
- offsetProp: 'top' |
|
164 |
- } |
|
165 |
- }; |
|
166 |
- return $.each(axes, function(aKey, axis) { |
|
167 |
- return $.each(_this.waypoints[aKey], function(i, waypoint) { |
|
168 |
- var adjustment, elementOffset, oldOffset, _ref, _ref1; |
|
169 |
- |
|
170 |
- adjustment = waypoint.options.offset; |
|
171 |
- oldOffset = waypoint.offset; |
|
172 |
- elementOffset = $.isWindow(waypoint.element) ? 0 : waypoint.$element.offset()[axis.offsetProp]; |
|
173 |
- if ($.isFunction(adjustment)) { |
|
174 |
- adjustment = adjustment.apply(waypoint.element); |
|
175 |
- } else if (typeof adjustment === 'string') { |
|
176 |
- adjustment = parseFloat(adjustment); |
|
177 |
- if (waypoint.options.offset.indexOf('%') > -1) { |
|
178 |
- adjustment = Math.ceil(axis.contextDimension * adjustment / 100); |
|
179 |
- } |
|
180 |
- } |
|
181 |
- waypoint.offset = elementOffset - axis.contextOffset + axis.contextScroll - adjustment; |
|
182 |
- if ((waypoint.options.onlyOnScroll && (oldOffset != null)) || !waypoint.enabled) { |
|
183 |
- return; |
|
184 |
- } |
|
185 |
- if (oldOffset !== null && (oldOffset < (_ref = axis.oldScroll) && _ref <= waypoint.offset)) { |
|
186 |
- return waypoint.trigger([axis.backward]); |
|
187 |
- } else if (oldOffset !== null && (oldOffset > (_ref1 = axis.oldScroll) && _ref1 >= waypoint.offset)) { |
|
188 |
- return waypoint.trigger([axis.forward]); |
|
189 |
- } else if (oldOffset === null && axis.oldScroll >= waypoint.offset) { |
|
190 |
- return waypoint.trigger([axis.forward]); |
|
191 |
- } |
|
192 |
- }); |
|
193 |
- }); |
|
194 |
- }; |
|
195 |
- |
|
196 |
- Context.prototype.checkEmpty = function() { |
|
197 |
- if ($.isEmptyObject(this.waypoints.horizontal) && $.isEmptyObject(this.waypoints.vertical)) { |
|
198 |
- this.$element.unbind([resizeEvent, scrollEvent].join(' ')); |
|
199 |
- return delete contexts[this.id]; |
|
200 |
- } |
|
201 |
- }; |
|
202 |
- |
|
203 |
- return Context; |
|
204 |
- |
|
205 |
- })(); |
|
206 |
- Waypoint = (function() { |
|
207 |
- function Waypoint($element, context, options) { |
|
208 |
- var idList, _ref; |
|
209 |
- |
|
210 |
- options = $.extend({}, $.fn[wp].defaults, options); |
|
211 |
- if (options.offset === 'bottom-in-view') { |
|
212 |
- options.offset = function() { |
|
213 |
- var contextHeight; |
|
214 |
- |
|
215 |
- contextHeight = $[wps]('viewportHeight'); |
|
216 |
- if (!$.isWindow(context.element)) { |
|
217 |
- contextHeight = context.$element.height(); |
|
218 |
- } |
|
219 |
- return contextHeight - $(this).outerHeight(); |
|
220 |
- }; |
|
221 |
- } |
|
222 |
- this.$element = $element; |
|
223 |
- this.element = $element[0]; |
|
224 |
- this.axis = options.horizontal ? 'horizontal' : 'vertical'; |
|
225 |
- this.callback = options.handler; |
|
226 |
- this.context = context; |
|
227 |
- this.enabled = options.enabled; |
|
228 |
- this.id = 'waypoints' + waypointCounter++; |
|
229 |
- this.offset = null; |
|
230 |
- this.options = options; |
|
231 |
- context.waypoints[this.axis][this.id] = this; |
|
232 |
- allWaypoints[this.axis][this.id] = this; |
|
233 |
- idList = (_ref = this.element[waypointKey]) != null ? _ref : []; |
|
234 |
- idList.push(this.id); |
|
235 |
- this.element[waypointKey] = idList; |
|
236 |
- } |
|
237 |
- |
|
238 |
- Waypoint.prototype.trigger = function(args) { |
|
239 |
- if (!this.enabled) { |
|
240 |
- return; |
|
241 |
- } |
|
242 |
- if (this.callback != null) { |
|
243 |
- this.callback.apply(this.element, args); |
|
244 |
- } |
|
245 |
- if (this.options.triggerOnce) { |
|
246 |
- return this.destroy(); |
|
247 |
- } |
|
248 |
- }; |
|
249 |
- |
|
250 |
- Waypoint.prototype.disable = function() { |
|
251 |
- return this.enabled = false; |
|
252 |
- }; |
|
253 |
- |
|
254 |
- Waypoint.prototype.enable = function() { |
|
255 |
- this.context.refresh(); |
|
256 |
- return this.enabled = true; |
|
257 |
- }; |
|
258 |
- |
|
259 |
- Waypoint.prototype.destroy = function() { |
|
260 |
- delete allWaypoints[this.axis][this.id]; |
|
261 |
- delete this.context.waypoints[this.axis][this.id]; |
|
262 |
- return this.context.checkEmpty(); |
|
263 |
- }; |
|
264 |
- |
|
265 |
- Waypoint.getWaypointsByElement = function(element) { |
|
266 |
- var all, ids; |
|
267 |
- |
|
268 |
- ids = element[waypointKey]; |
|
269 |
- if (!ids) { |
|
270 |
- return []; |
|
271 |
- } |
|
272 |
- all = $.extend({}, allWaypoints.horizontal, allWaypoints.vertical); |
|
273 |
- return $.map(ids, function(id) { |
|
274 |
- return all[id]; |
|
275 |
- }); |
|
276 |
- }; |
|
277 |
- |
|
278 |
- return Waypoint; |
|
279 |
- |
|
280 |
- })(); |
|
281 |
- methods = { |
|
282 |
- init: function(f, options) { |
|
283 |
- var _ref; |
|
284 |
- |
|
285 |
- if (options == null) { |
|
286 |
- options = {}; |
|
287 |
- } |
|
288 |
- if ((_ref = options.handler) == null) { |
|
289 |
- options.handler = f; |
|
290 |
- } |
|
291 |
- this.each(function() { |
|
292 |
- var $this, context, contextElement, _ref1; |
|
293 |
- |
|
294 |
- $this = $(this); |
|
295 |
- contextElement = (_ref1 = options.context) != null ? _ref1 : $.fn[wp].defaults.context; |
|
296 |
- if (!$.isWindow(contextElement)) { |
|
297 |
- contextElement = $this.closest(contextElement); |
|
298 |
- } |
|
299 |
- contextElement = $(contextElement); |
|
300 |
- context = contexts[contextElement[0][contextKey]]; |
|
301 |
- if (!context) { |
|
302 |
- context = new Context(contextElement); |
|
303 |
- } |
|
304 |
- return new Waypoint($this, context, options); |
|
305 |
- }); |
|
306 |
- $[wps]('refresh'); |
|
307 |
- return this; |
|
308 |
- }, |
|
309 |
- disable: function() { |
|
310 |
- return methods._invoke.call(this, 'disable'); |
|
311 |
- }, |
|
312 |
- enable: function() { |
|
313 |
- return methods._invoke.call(this, 'enable'); |
|
314 |
- }, |
|
315 |
- destroy: function() { |
|
316 |
- return methods._invoke.call(this, 'destroy'); |
|
317 |
- }, |
|
318 |
- prev: function(axis, selector) { |
|
319 |
- return methods._traverse.call(this, axis, selector, function(stack, index, waypoints) { |
|
320 |
- if (index > 0) { |
|
321 |
- return stack.push(waypoints[index - 1]); |
|
322 |
- } |
|
323 |
- }); |
|
324 |
- }, |
|
325 |
- next: function(axis, selector) { |
|
326 |
- return methods._traverse.call(this, axis, selector, function(stack, index, waypoints) { |
|
327 |
- if (index < waypoints.length - 1) { |
|
328 |
- return stack.push(waypoints[index + 1]); |
|
329 |
- } |
|
330 |
- }); |
|
331 |
- }, |
|
332 |
- _traverse: function(axis, selector, push) { |
|
333 |
- var stack, waypoints; |
|
334 |
- |
|
335 |
- if (axis == null) { |
|
336 |
- axis = 'vertical'; |
|
337 |
- } |
|
338 |
- if (selector == null) { |
|
339 |
- selector = window; |
|
340 |
- } |
|
341 |
- waypoints = jQMethods.aggregate(selector); |
|
342 |
- stack = []; |
|
343 |
- this.each(function() { |
|
344 |
- var index; |
|
345 |
- |
|
346 |
- index = $.inArray(this, waypoints[axis]); |
|
347 |
- return push(stack, index, waypoints[axis]); |
|
348 |
- }); |
|
349 |
- return this.pushStack(stack); |
|
350 |
- }, |
|
351 |
- _invoke: function(method) { |
|
352 |
- this.each(function() { |
|
353 |
- var waypoints; |
|
354 |
- |
|
355 |
- waypoints = Waypoint.getWaypointsByElement(this); |
|
356 |
- return $.each(waypoints, function(i, waypoint) { |
|
357 |
- waypoint[method](); |
|
358 |
- return true; |
|
359 |
- }); |
|
360 |
- }); |
|
361 |
- return this; |
|
362 |
- } |
|
363 |
- }; |
|
364 |
- $.fn[wp] = function() { |
|
365 |
- var args, method; |
|
366 |
- |
|
367 |
- method = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : []; |
|
368 |
- if (methods[method]) { |
|
369 |
- return methods[method].apply(this, args); |
|
370 |
- } else if ($.isFunction(method)) { |
|
371 |
- return methods.init.apply(this, arguments); |
|
372 |
- } else if ($.isPlainObject(method)) { |
|
373 |
- return methods.init.apply(this, [null, method]); |
|
374 |
- } else if (!method) { |
|
375 |
- return $.error("jQuery Waypoints needs a callback function or handler option."); |
|
376 |
- } else { |
|
377 |
- return $.error("The " + method + " method does not exist in jQuery Waypoints."); |
|
378 |
- } |
|
379 |
- }; |
|
380 |
- $.fn[wp].defaults = { |
|
381 |
- context: window, |
|
382 |
- continuous: true, |
|
383 |
- enabled: true, |
|
384 |
- horizontal: false, |
|
385 |
- offset: 0, |
|
386 |
- triggerOnce: false |
|
387 |
- }; |
|
388 |
- jQMethods = { |
|
389 |
- refresh: function() { |
|
390 |
- return $.each(contexts, function(i, context) { |
|
391 |
- return context.refresh(); |
|
392 |
- }); |
|
393 |
- }, |
|
394 |
- viewportHeight: function() { |
|
395 |
- var _ref; |
|
396 |
- |
|
397 |
- return (_ref = window.innerHeight) != null ? _ref : $w.height(); |
|
398 |
- }, |
|
399 |
- aggregate: function(contextSelector) { |
|
400 |
- var collection, waypoints, _ref; |
|
401 |
- |
|
402 |
- collection = allWaypoints; |
|
403 |
- if (contextSelector) { |
|
404 |
- collection = (_ref = contexts[$(contextSelector)[0][contextKey]]) != null ? _ref.waypoints : void 0; |
|
405 |
- } |
|
406 |
- if (!collection) { |
|
407 |
- return []; |
|
408 |
- } |
|
409 |
- waypoints = { |
|
410 |
- horizontal: [], |
|
411 |
- vertical: [] |
|
412 |
- }; |
|
413 |
- $.each(waypoints, function(axis, arr) { |
|
414 |
- $.each(collection[axis], function(key, waypoint) { |
|
415 |
- return arr.push(waypoint); |
|
416 |
- }); |
|
417 |
- arr.sort(function(a, b) { |
|
418 |
- return a.offset - b.offset; |
|
419 |
- }); |
|
420 |
- waypoints[axis] = $.map(arr, function(waypoint) { |
|
421 |
- return waypoint.element; |
|
422 |
- }); |
|
423 |
- return waypoints[axis] = $.unique(waypoints[axis]); |
|
424 |
- }); |
|
425 |
- return waypoints; |
|
426 |
- }, |
|
427 |
- above: function(contextSelector) { |
|
428 |
- if (contextSelector == null) { |
|
429 |
- contextSelector = window; |
|
430 |
- } |
|
431 |
- return jQMethods._filter(contextSelector, 'vertical', function(context, waypoint) { |
|
432 |
- return waypoint.offset <= context.oldScroll.y; |
|
433 |
- }); |
|
434 |
- }, |
|
435 |
- below: function(contextSelector) { |
|
436 |
- if (contextSelector == null) { |
|
437 |
- contextSelector = window; |
|
438 |
- } |
|
439 |
- return jQMethods._filter(contextSelector, 'vertical', function(context, waypoint) { |
|
440 |
- return waypoint.offset > context.oldScroll.y; |
|
441 |
- }); |
|
442 |
- }, |
|
443 |
- left: function(contextSelector) { |
|
444 |
- if (contextSelector == null) { |
|
445 |
- contextSelector = window; |
|
446 |
- } |
|
447 |
- return jQMethods._filter(contextSelector, 'horizontal', function(context, waypoint) { |
|
448 |
- return waypoint.offset <= context.oldScroll.x; |
|
449 |
- }); |
|
450 |
- }, |
|
451 |
- right: function(contextSelector) { |
|
452 |
- if (contextSelector == null) { |
|
453 |
- contextSelector = window; |
|
454 |
- } |
|
455 |
- return jQMethods._filter(contextSelector, 'horizontal', function(context, waypoint) { |
|
456 |
- return waypoint.offset > context.oldScroll.x; |
|
457 |
- }); |
|
458 |
- }, |
|
459 |
- enable: function() { |
|
460 |
- return jQMethods._invoke('enable'); |
|
461 |
- }, |
|
462 |
- disable: function() { |
|
463 |
- return jQMethods._invoke('disable'); |
|
464 |
- }, |
|
465 |
- destroy: function() { |
|
466 |
- return jQMethods._invoke('destroy'); |
|
467 |
- }, |
|
468 |
- extendFn: function(methodName, f) { |
|
469 |
- return methods[methodName] = f; |
|
470 |
- }, |
|
471 |
- _invoke: function(method) { |
|
472 |
- var waypoints; |
|
473 |
- |
|
474 |
- waypoints = $.extend({}, allWaypoints.vertical, allWaypoints.horizontal); |
|
475 |
- return $.each(waypoints, function(key, waypoint) { |
|
476 |
- waypoint[method](); |
|
477 |
- return true; |
|
478 |
- }); |
|
479 |
- }, |
|
480 |
- _filter: function(selector, axis, test) { |
|
481 |
- var context, waypoints; |
|
482 |
- |
|
483 |
- context = contexts[$(selector)[0][contextKey]]; |
|
484 |
- if (!context) { |
|
485 |
- return []; |
|
486 |
- } |
|
487 |
- waypoints = []; |
|
488 |
- $.each(context.waypoints[axis], function(i, waypoint) { |
|
489 |
- if (test(context, waypoint)) { |
|
490 |
- return waypoints.push(waypoint); |
|
491 |
- } |
|
492 |
- }); |
|
493 |
- waypoints.sort(function(a, b) { |
|
494 |
- return a.offset - b.offset; |
|
495 |
- }); |
|
496 |
- return $.map(waypoints, function(waypoint) { |
|
497 |
- return waypoint.element; |
|
498 |
- }); |
|
499 |
- } |
|
500 |
- }; |
|
501 |
- $[wps] = function() { |
|
502 |
- var args, method; |
|
503 |
- |
|
504 |
- method = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : []; |
|
505 |
- if (jQMethods[method]) { |
|
506 |
- return jQMethods[method].apply(null, args); |
|
507 |
- } else { |
|
508 |
- return jQMethods.aggregate.call(null, method); |
|
509 |
- } |
|
510 |
- }; |
|
511 |
- $[wps].settings = { |
|
512 |
- resizeThrottle: 100, |
|
513 |
- scrollThrottle: 30 |
|
514 |
- }; |
|
515 |
- return $w.load(function() { |
|
516 |
- return $[wps]('refresh'); |
|
517 |
- }); |
|
518 |
- }); |
|
519 |
- |
|
520 |
-}).call(this); |
521 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,8 +0,0 @@ |
1 |
-// Generated by CoffeeScript 1.6.2 |
|
2 |
-/* |
|
3 |
-jQuery Waypoints - v2.0.4 |
|
4 |
-Copyright (c) 2011-2014 Caleb Troughton |
|
5 |
-Dual licensed under the MIT license and GPL license. |
|
6 |
-https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt |
|
7 |
-*/ |
|
8 |
-(function(){var t=[].indexOf||function(t){for(var e=0,n=this.length;e<n;e++){if(e in this&&this[e]===t)return e}return-1},e=[].slice;(function(t,e){if(typeof define==="function"&&define.amd){return define("waypoints",["jquery"],function(n){return e(n,t)})}else{return e(t.jQuery,t)}})(this,function(n,r){var i,o,l,s,f,u,c,a,h,d,p,y,v,w,g,m;i=n(r);a=t.call(r,"ontouchstart")>=0;s={horizontal:{},vertical:{}};f=1;c={};u="waypoints-context-id";p="resize.waypoints";y="scroll.waypoints";v=1;w="waypoints-waypoint-ids";g="waypoint";m="waypoints";o=function(){function t(t){var e=this;this.$element=t;this.element=t[0];this.didResize=false;this.didScroll=false;this.id="context"+f++;this.oldScroll={x:t.scrollLeft(),y:t.scrollTop()};this.waypoints={horizontal:{},vertical:{}};this.element[u]=this.id;c[this.id]=this;t.bind(y,function(){var t;if(!(e.didScroll||a)){e.didScroll=true;t=function(){e.doScroll();return e.didScroll=false};return r.setTimeout(t,n[m].settings.scrollThrottle)}});t.bind(p,function(){var t;if(!e.didResize){e.didResize=true;t=function(){n[m]("refresh");return e.didResize=false};return r.setTimeout(t,n[m].settings.resizeThrottle)}})}t.prototype.doScroll=function(){var t,e=this;t={horizontal:{newScroll:this.$element.scrollLeft(),oldScroll:this.oldScroll.x,forward:"right",backward:"left"},vertical:{newScroll:this.$element.scrollTop(),oldScroll:this.oldScroll.y,forward:"down",backward:"up"}};if(a&&(!t.vertical.oldScroll||!t.vertical.newScroll)){n[m]("refresh")}n.each(t,function(t,r){var i,o,l;l=[];o=r.newScroll>r.oldScroll;i=o?r.forward:r.backward;n.each(e.waypoints[t],function(t,e){var n,i;if(r.oldScroll<(n=e.offset)&&n<=r.newScroll){return l.push(e)}else if(r.newScroll<(i=e.offset)&&i<=r.oldScroll){return l.push(e)}});l.sort(function(t,e){return t.offset-e.offset});if(!o){l.reverse()}return n.each(l,function(t,e){if(e.options.continuous||t===l.length-1){return e.trigger([i])}})});return this.oldScroll={x:t.horizontal.newScroll,y:t.vertical.newScroll}};t.prototype.refresh=function(){var t,e,r,i=this;r=n.isWindow(this.element);e=this.$element.offset();this.doScroll();t={horizontal:{contextOffset:r?0:e.left,contextScroll:r?0:this.oldScroll.x,contextDimension:this.$element.width(),oldScroll:this.oldScroll.x,forward:"right",backward:"left",offsetProp:"left"},vertical:{contextOffset:r?0:e.top,contextScroll:r?0:this.oldScroll.y,contextDimension:r?n[m]("viewportHeight"):this.$element.height(),oldScroll:this.oldScroll.y,forward:"down",backward:"up",offsetProp:"top"}};return n.each(t,function(t,e){return n.each(i.waypoints[t],function(t,r){var i,o,l,s,f;i=r.options.offset;l=r.offset;o=n.isWindow(r.element)?0:r.$element.offset()[e.offsetProp];if(n.isFunction(i)){i=i.apply(r.element)}else if(typeof i==="string"){i=parseFloat(i);if(r.options.offset.indexOf("%")>-1){i=Math.ceil(e.contextDimension*i/100)}}r.offset=o-e.contextOffset+e.contextScroll-i;if(r.options.onlyOnScroll&&l!=null||!r.enabled){return}if(l!==null&&l<(s=e.oldScroll)&&s<=r.offset){return r.trigger([e.backward])}else if(l!==null&&l>(f=e.oldScroll)&&f>=r.offset){return r.trigger([e.forward])}else if(l===null&&e.oldScroll>=r.offset){return r.trigger([e.forward])}})})};t.prototype.checkEmpty=function(){if(n.isEmptyObject(this.waypoints.horizontal)&&n.isEmptyObject(this.waypoints.vertical)){this.$element.unbind([p,y].join(" "));return delete c[this.id]}};return t}();l=function(){function t(t,e,r){var i,o;r=n.extend({},n.fn[g].defaults,r);if(r.offset==="bottom-in-view"){r.offset=function(){var t;t=n[m]("viewportHeight");if(!n.isWindow(e.element)){t=e.$element.height()}return t-n(this).outerHeight()}}this.$element=t;this.element=t[0];this.axis=r.horizontal?"horizontal":"vertical";this.callback=r.handler;this.context=e;this.enabled=r.enabled;this.id="waypoints"+v++;this.offset=null;this.options=r;e.waypoints[this.axis][this.id]=this;s[this.axis][this.id]=this;i=(o=this.element[w])!=null?o:[];i.push(this.id);this.element[w]=i}t.prototype.trigger=function(t){if(!this.enabled){return}if(this.callback!=null){this.callback.apply(this.element,t)}if(this.options.triggerOnce){return this.destroy()}};t.prototype.disable=function(){return this.enabled=false};t.prototype.enable=function(){this.context.refresh();return this.enabled=true};t.prototype.destroy=function(){delete s[this.axis][this.id];delete this.context.waypoints[this.axis][this.id];return this.context.checkEmpty()};t.getWaypointsByElement=function(t){var e,r;r=t[w];if(!r){return[]}e=n.extend({},s.horizontal,s.vertical);return n.map(r,function(t){return e[t]})};return t}();d={init:function(t,e){var r;if(e==null){e={}}if((r=e.handler)==null){e.handler=t}this.each(function(){var t,r,i,s;t=n(this);i=(s=e.context)!=null?s:n.fn[g].defaults.context;if(!n.isWindow(i)){i=t.closest(i)}i=n(i);r=c[i[0][u]];if(!r){r=new o(i)}return new l(t,r,e)});n[m]("refresh");return this},disable:function(){return d._invoke.call(this,"disable")},enable:function(){return d._invoke.call(this,"enable")},destroy:function(){return d._invoke.call(this,"destroy")},prev:function(t,e){return d._traverse.call(this,t,e,function(t,e,n){if(e>0){return t.push(n[e-1])}})},next:function(t,e){return d._traverse.call(this,t,e,function(t,e,n){if(e<n.length-1){return t.push(n[e+1])}})},_traverse:function(t,e,i){var o,l;if(t==null){t="vertical"}if(e==null){e=r}l=h.aggregate(e);o=[];this.each(function(){var e;e=n.inArray(this,l[t]);return i(o,e,l[t])});return this.pushStack(o)},_invoke:function(t){this.each(function(){var e;e=l.getWaypointsByElement(this);return n.each(e,function(e,n){n[t]();return true})});return this}};n.fn[g]=function(){var t,r;r=arguments[0],t=2<=arguments.length?e.call(arguments,1):[];if(d[r]){return d[r].apply(this,t)}else if(n.isFunction(r)){return d.init.apply(this,arguments)}else if(n.isPlainObject(r)){return d.init.apply(this,[null,r])}else if(!r){return n.error("jQuery Waypoints needs a callback function or handler option.")}else{return n.error("The "+r+" method does not exist in jQuery Waypoints.")}};n.fn[g].defaults={context:r,continuous:true,enabled:true,horizontal:false,offset:0,triggerOnce:false};h={refresh:function(){return n.each(c,function(t,e){return e.refresh()})},viewportHeight:function(){var t;return(t=r.innerHeight)!=null?t:i.height()},aggregate:function(t){var e,r,i;e=s;if(t){e=(i=c[n(t)[0][u]])!=null?i.waypoints:void 0}if(!e){return[]}r={horizontal:[],vertical:[]};n.each(r,function(t,i){n.each(e[t],function(t,e){return i.push(e)});i.sort(function(t,e){return t.offset-e.offset});r[t]=n.map(i,function(t){return t.element});return r[t]=n.unique(r[t])});return r},above:function(t){if(t==null){t=r}return h._filter(t,"vertical",function(t,e){return e.offset<=t.oldScroll.y})},below:function(t){if(t==null){t=r}return h._filter(t,"vertical",function(t,e){return e.offset>t.oldScroll.y})},left:function(t){if(t==null){t=r}return h._filter(t,"horizontal",function(t,e){return e.offset<=t.oldScroll.x})},right:function(t){if(t==null){t=r}return h._filter(t,"horizontal",function(t,e){return e.offset>t.oldScroll.x})},enable:function(){return h._invoke("enable")},disable:function(){return h._invoke("disable")},destroy:function(){return h._invoke("destroy")},extendFn:function(t,e){return d[t]=e},_invoke:function(t){var e;e=n.extend({},s.vertical,s.horizontal);return n.each(e,function(e,n){n[t]();return true})},_filter:function(t,e,r){var i,o;i=c[n(t)[0][u]];if(!i){return[]}o=[];n.each(i.waypoints[e],function(t,e){if(r(i,e)){return o.push(e)}});o.sort(function(t,e){return t.offset-e.offset});return n.map(o,function(t){return t.element})}};n[m]=function(){var t,n;n=arguments[0],t=2<=arguments.length?e.call(arguments,1):[];if(h[n]){return h[n].apply(null,t)}else{return h.aggregate.call(null,n)}};n[m].settings={resizeThrottle:100,scrollThrottle:30};return i.load(function(){return n[m]("refresh")})})}).call(this); |
|
9 | 0 |
\ No newline at end of file |
10 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,23 +0,0 @@ |
1 |
-Copyright (c) 2011-2012 Caleb Troughton |
|
2 |
- |
|
3 |
- |
|
4 |
-The MIT License |
|
5 |
- |
|
6 |
-Permission is hereby granted, free of charge, to any person obtaining a copy |
|
7 |
-of this software and associated documentation files (the "Software"), to deal |
|
8 |
-in the Software without restriction, including without limitation the rights |
|
9 |
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
10 |
-copies of the Software, and to permit persons to whom the Software is |
|
11 |
-furnished to do so, subject to the following conditions: |
|
12 |
- |
|
13 |
-The above copyright notice and this permission notice shall be included in |
|
14 |
-all copies or substantial portions of the Software. |
|
15 |
- |
|
16 |
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
17 |
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
18 |
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
19 |
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
20 |
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
21 |
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
22 |
-THE SOFTWARE. |
|
23 | 0 |
\ No newline at end of file |
24 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,47 +0,0 @@ |
1 |
-# jQuery Waypoints |
|
2 |
- |
|
3 |
-Waypoints is a jQuery plugin that makes it easy to execute a function whenever you scroll to an element. |
|
4 |
- |
|
5 |
-```js |
|
6 |
-$('.thing').waypoint(function() { |
|
7 |
- alert('You have scrolled to a thing.'); |
|
8 |
-}); |
|
9 |
-``` |
|
10 |
-If you're new to Waypoints, check out the [Get Started](http://imakewebthings.github.com/jquery-waypoints/#get-started) section. |
|
11 |
- |
|
12 |
-[Read the full documentation](http://imakewebthings.github.com/jquery-waypoints/#docs) for more details on usage and customization. |
|
13 |
- |
|
14 |
-## Shortcuts |
|
15 |
- |
|
16 |
-In addition to the normal Waypoints script, extensions exist to make common UI patterns just a little easier to implement: |
|
17 |
- |
|
18 |
-- [Infinite Scrolling](http://imakewebthings.github.com/jquery-waypoints/shortcuts/infinite-scroll) |
|
19 |
-- [Sticky Elements](http://imakewebthings.github.com/jquery-waypoints/shortcuts/sticky-elements) |
|
20 |
- |
|
21 |
-## Examples |
|
22 |
- |
|
23 |
-Waypoints can also be used as a base for your own custom UI patterns. Here are a few examples: |
|
24 |
- |
|
25 |
-- [Scroll Analytics](http://imakewebthings.github.com/jquery-waypoints/examples/scroll-analytics) |
|
26 |
-- [Dial Controls](http://imakewebthings.github.com/jquery-waypoints/examples/dial-controls) |
|
27 |
- |
|
28 |
-## AMD Module Loader Support |
|
29 |
- |
|
30 |
-If you're using an AMD loader like [RequireJS](http://requirejs.org/), Waypoints registers itself as a named module, `'waypoints'`. Shortcut scripts are anonymous modules. |
|
31 |
- |
|
32 |
-## Development Environment |
|
33 |
- |
|
34 |
-If you want to contribute to Waypoints, I love pull requests that include changes to the source `coffee` files as well as the compiled JS and minified files. You can set up the same environment by running `make setup` (which just aliases to `npm install`). This will install the version of CoffeeScript and UglifyJS that I'm using. From there, running `make build` will compile and minify all the necessary files. Test coffee files are compiled on the fly, so compile and minify do not apply to those files. |
|
35 |
- |
|
36 |
-## License |
|
37 |
- |
|
38 |
-Copyright (c) 2011-2014 Caleb Troughton |
|
39 |
-Licensed under the [MIT license](https://github.com/imakewebthings/jquery-waypoints/blob/master/licenses.txt). |
|
40 |
- |
|
41 |
-## Support |
|
42 |
- |
|
43 |
-Unit tests for Waypoints are written with [Jasmine](http://pivotal.github.com/jasmine/) and [jasmine-jquery](https://github.com/velesin/jasmine-jquery). You can [run them here](http://imakewebthings.github.com/jquery-waypoints/test/). If any of the tests fail, please open an issue and include the browser used, operating system, and description of the failed test. |
|
44 |
- |
|
45 |
-## Donations |
|
46 |
- |
|
47 |
-[](https://www.gittip.com/imakewebthings/ "Donate weekly to this project using Gittip") |
4 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,647 +0,0 @@ |
1 |
-/*! |
|
2 |
-Waypoints - 3.1.1 |
|
3 |
-Copyright © 2011-2015 Caleb Troughton |
|
4 |
-Licensed under the MIT license. |
|
5 |
-https://github.com/imakewebthings/waypoints/blog/master/licenses.txt |
|
6 |
-*/ |
|
7 |
-(function() { |
|
8 |
- 'use strict' |
|
9 |
- |
|
10 |
- var keyCounter = 0 |
|
11 |
- var allWaypoints = {} |
|
12 |
- |
|
13 |
- /* http://imakewebthings.com/waypoints/api/waypoint */ |
|
14 |
- function Waypoint(options) { |
|
15 |
- if (!options) { |
|
16 |
- throw new Error('No options passed to Waypoint constructor') |
|
17 |
- } |
|
18 |
- if (!options.element) { |
|
19 |
- throw new Error('No element option passed to Waypoint constructor') |
|
20 |
- } |
|
21 |
- if (!options.handler) { |
|
22 |
- throw new Error('No handler option passed to Waypoint constructor') |
|
23 |
- } |
|
24 |
- |
|
25 |
- this.key = 'waypoint-' + keyCounter |
|
26 |
- this.options = Waypoint.Adapter.extend({}, Waypoint.defaults, options) |
|
27 |
- this.element = this.options.element |
|
28 |
- this.adapter = new Waypoint.Adapter(this.element) |
|
29 |
- this.callback = options.handler |
|
30 |
- this.axis = this.options.horizontal ? 'horizontal' : 'vertical' |
|
31 |
- this.enabled = this.options.enabled |
|
32 |
- this.triggerPoint = null |
|
33 |
- this.group = Waypoint.Group.findOrCreate({ |
|
34 |
- name: this.options.group, |
|
35 |
- axis: this.axis |
|
36 |
- }) |
|
37 |
- this.context = Waypoint.Context.findOrCreateByElement(this.options.context) |
|
38 |
- |
|
39 |
- if (Waypoint.offsetAliases[this.options.offset]) { |
|
40 |
- this.options.offset = Waypoint.offsetAliases[this.options.offset] |
|
41 |
- } |
|
42 |
- this.group.add(this) |
|
43 |
- this.context.add(this) |
|
44 |
- allWaypoints[this.key] = this |
|
45 |
- keyCounter += 1 |
|
46 |
- } |
|
47 |
- |
|
48 |
- /* Private */ |
|
49 |
- Waypoint.prototype.queueTrigger = function(direction) { |
|
50 |
- this.group.queueTrigger(this, direction) |
|
51 |
- } |
|
52 |
- |
|
53 |
- /* Private */ |
|
54 |
- Waypoint.prototype.trigger = function(args) { |
|
55 |
- if (!this.enabled) { |
|
56 |
- return |
|
57 |
- } |
|
58 |
- if (this.callback) { |
|
59 |
- this.callback.apply(this, args) |
|
60 |
- } |
|
61 |
- } |
|
62 |
- |
|
63 |
- /* Public */ |
|
64 |
- /* http://imakewebthings.com/waypoints/api/destroy */ |
|
65 |
- Waypoint.prototype.destroy = function() { |
|
66 |
- this.context.remove(this) |
|
67 |
- this.group.remove(this) |
|
68 |
- delete allWaypoints[this.key] |
|
69 |
- } |
|
70 |
- |
|
71 |
- /* Public */ |
|
72 |
- /* http://imakewebthings.com/waypoints/api/disable */ |
|
73 |
- Waypoint.prototype.disable = function() { |
|
74 |
- this.enabled = false |
|
75 |
- return this |
|
76 |
- } |
|
77 |
- |
|
78 |
- /* Public */ |
|
79 |
- /* http://imakewebthings.com/waypoints/api/enable */ |
|
80 |
- Waypoint.prototype.enable = function() { |
|
81 |
- this.context.refresh() |
|
82 |
- this.enabled = true |
|
83 |
- return this |
|
84 |
- } |
|
85 |
- |
|
86 |
- /* Public */ |
|
87 |
- /* http://imakewebthings.com/waypoints/api/next */ |
|
88 |
- Waypoint.prototype.next = function() { |
|
89 |
- return this.group.next(this) |
|
90 |
- } |
|
91 |
- |
|
92 |
- /* Public */ |
|
93 |
- /* http://imakewebthings.com/waypoints/api/previous */ |
|
94 |
- Waypoint.prototype.previous = function() { |
|
95 |
- return this.group.previous(this) |
|
96 |
- } |
|
97 |
- |
|
98 |
- /* Private */ |
|
99 |
- Waypoint.invokeAll = function(method) { |
|
100 |
- var allWaypointsArray = [] |
|
101 |
- for (var waypointKey in allWaypoints) { |
|
102 |
- allWaypointsArray.push(allWaypoints[waypointKey]) |
|
103 |
- } |
|
104 |
- for (var i = 0, end = allWaypointsArray.length; i < end; i++) { |
|
105 |
- allWaypointsArray[i][method]() |
|
106 |
- } |
|
107 |
- } |
|
108 |
- |
|
109 |
- /* Public */ |
|
110 |
- /* http://imakewebthings.com/waypoints/api/destroy-all */ |
|
111 |
- Waypoint.destroyAll = function() { |
|
112 |
- Waypoint.invokeAll('destroy') |
|
113 |
- } |
|
114 |
- |
|
115 |
- /* Public */ |
|
116 |
- /* http://imakewebthings.com/waypoints/api/disable-all */ |
|
117 |
- Waypoint.disableAll = function() { |
|
118 |
- Waypoint.invokeAll('disable') |
|
119 |
- } |
|
120 |
- |
|
121 |
- /* Public */ |
|
122 |
- /* http://imakewebthings.com/waypoints/api/enable-all */ |
|
123 |
- Waypoint.enableAll = function() { |
|
124 |
- Waypoint.invokeAll('enable') |
|
125 |
- } |
|
126 |
- |
|
127 |
- /* Public */ |
|
128 |
- /* http://imakewebthings.com/waypoints/api/refresh-all */ |
|
129 |
- Waypoint.refreshAll = function() { |
|
130 |
- Waypoint.Context.refreshAll() |
|
131 |
- } |
|
132 |
- |
|
133 |
- /* Public */ |
|
134 |
- /* http://imakewebthings.com/waypoints/api/viewport-height */ |
|
135 |
- Waypoint.viewportHeight = function() { |
|
136 |
- return window.innerHeight || document.documentElement.clientHeight |
|
137 |
- } |
|
138 |
- |
|
139 |
- /* Public */ |
|
140 |
- /* http://imakewebthings.com/waypoints/api/viewport-width */ |
|
141 |
- Waypoint.viewportWidth = function() { |
|
142 |
- return document.documentElement.clientWidth |
|
143 |
- } |
|
144 |
- |
|
145 |
- Waypoint.adapters = [] |
|
146 |
- |
|
147 |
- Waypoint.defaults = { |
|
148 |
- context: window, |
|
149 |
- continuous: true, |
|
150 |
- enabled: true, |
|
151 |
- group: 'default', |
|
152 |
- horizontal: false, |
|
153 |
- offset: 0 |
|
154 |
- } |
|
155 |
- |
|
156 |
- Waypoint.offsetAliases = { |
|
157 |
- 'bottom-in-view': function() { |
|
158 |
- return this.context.innerHeight() - this.adapter.outerHeight() |
|
159 |
- }, |
|
160 |
- 'right-in-view': function() { |
|
161 |
- return this.context.innerWidth() - this.adapter.outerWidth() |
|
162 |
- } |
|
163 |
- } |
|
164 |
- |
|
165 |
- window.Waypoint = Waypoint |
|
166 |
-}()) |
|
167 |
-;(function() { |
|
168 |
- 'use strict' |
|
169 |
- |
|
170 |
- function requestAnimationFrameShim(callback) { |
|
171 |
- window.setTimeout(callback, 1000 / 60) |
|
172 |
- } |
|
173 |
- |
|
174 |
- var keyCounter = 0 |
|
175 |
- var contexts = {} |
|
176 |
- var Waypoint = window.Waypoint |
|
177 |
- var oldWindowLoad = window.onload |
|
178 |
- |
|
179 |
- /* http://imakewebthings.com/waypoints/api/context */ |
|
180 |
- function Context(element) { |
|
181 |
- this.element = element |
|
182 |
- this.Adapter = Waypoint.Adapter |
|
183 |
- this.adapter = new this.Adapter(element) |
|
184 |
- this.key = 'waypoint-context-' + keyCounter |
|
185 |
- this.didScroll = false |
|
186 |
- this.didResize = false |
|
187 |
- this.oldScroll = { |
|
188 |
- x: this.adapter.scrollLeft(), |
|
189 |
- y: this.adapter.scrollTop() |
|
190 |
- } |
|
191 |
- this.waypoints = { |
|
192 |
- vertical: {}, |
|
193 |
- horizontal: {} |
|
194 |
- } |
|
195 |
- |
|
196 |
- element.waypointContextKey = this.key |
|
197 |
- contexts[element.waypointContextKey] = this |
|
198 |
- keyCounter += 1 |
|
199 |
- |
|
200 |
- this.createThrottledScrollHandler() |
|
201 |
- this.createThrottledResizeHandler() |
|
202 |
- } |
|
203 |
- |
|
204 |
- /* Private */ |
|
205 |
- Context.prototype.add = function(waypoint) { |
|
206 |
- var axis = waypoint.options.horizontal ? 'horizontal' : 'vertical' |
|
207 |
- this.waypoints[axis][waypoint.key] = waypoint |
|
208 |
- this.refresh() |
|
209 |
- } |
|
210 |
- |
|
211 |
- /* Private */ |
|
212 |
- Context.prototype.checkEmpty = function() { |
|
213 |
- var horizontalEmpty = this.Adapter.isEmptyObject(this.waypoints.horizontal) |
|
214 |
- var verticalEmpty = this.Adapter.isEmptyObject(this.waypoints.vertical) |
|
215 |
- if (horizontalEmpty && verticalEmpty) { |
|
216 |
- this.adapter.off('.waypoints') |
|
217 |
- delete contexts[this.key] |
|
218 |
- } |
|
219 |
- } |
|
220 |
- |
|
221 |
- /* Private */ |
|
222 |
- Context.prototype.createThrottledResizeHandler = function() { |
|
223 |
- var self = this |
|
224 |
- |
|
225 |
- function resizeHandler() { |
|
226 |
- self.handleResize() |
|
227 |
- self.didResize = false |
|
228 |
- } |
|
229 |
- |
|
230 |
- this.adapter.on('resize.waypoints', function() { |
|
231 |
- if (!self.didResize) { |
|
232 |
- self.didResize = true |
|
233 |
- Waypoint.requestAnimationFrame(resizeHandler) |
|
234 |
- } |
|
235 |
- }) |
|
236 |
- } |
|
237 |
- |
|
238 |
- /* Private */ |
|
239 |
- Context.prototype.createThrottledScrollHandler = function() { |
|
240 |
- var self = this |
|
241 |
- function scrollHandler() { |
|
242 |
- self.handleScroll() |
|
243 |
- self.didScroll = false |
|
244 |
- } |
|
245 |
- |
|
246 |
- this.adapter.on('scroll.waypoints', function() { |
|
247 |
- if (!self.didScroll || Waypoint.isTouch) { |
|
248 |
- self.didScroll = true |
|
249 |
- Waypoint.requestAnimationFrame(scrollHandler) |
|
250 |
- } |
|
251 |
- }) |
|
252 |
- } |
|
253 |
- |
|
254 |
- /* Private */ |
|
255 |
- Context.prototype.handleResize = function() { |
|
256 |
- Waypoint.Context.refreshAll() |
|
257 |
- } |
|
258 |
- |
|
259 |
- /* Private */ |
|
260 |
- Context.prototype.handleScroll = function() { |
|
261 |
- var triggeredGroups = {} |
|
262 |
- var axes = { |
|
263 |
- horizontal: { |
|
264 |
- newScroll: this.adapter.scrollLeft(), |
|
265 |
- oldScroll: this.oldScroll.x, |
|
266 |
- forward: 'right', |
|
267 |
- backward: 'left' |
|
268 |
- }, |
|
269 |
- vertical: { |
|
270 |
- newScroll: this.adapter.scrollTop(), |
|
271 |
- oldScroll: this.oldScroll.y, |
|
272 |
- forward: 'down', |
|
273 |
- backward: 'up' |
|
274 |
- } |
|
275 |
- } |
|
276 |
- |
|
277 |
- for (var axisKey in axes) { |
|
278 |
- var axis = axes[axisKey] |
|
279 |
- var isForward = axis.newScroll > axis.oldScroll |
|
280 |
- var direction = isForward ? axis.forward : axis.backward |
|
281 |
- |
|
282 |
- for (var waypointKey in this.waypoints[axisKey]) { |
|
283 |
- var waypoint = this.waypoints[axisKey][waypointKey] |
|
284 |
- var wasBeforeTriggerPoint = axis.oldScroll < waypoint.triggerPoint |
|
285 |
- var nowAfterTriggerPoint = axis.newScroll >= waypoint.triggerPoint |
|
286 |
- var crossedForward = wasBeforeTriggerPoint && nowAfterTriggerPoint |
|
287 |
- var crossedBackward = !wasBeforeTriggerPoint && !nowAfterTriggerPoint |
|
288 |
- if (crossedForward || crossedBackward) { |
|
289 |
- waypoint.queueTrigger(direction) |
|
290 |
- triggeredGroups[waypoint.group.id] = waypoint.group |
|
291 |
- } |
|
292 |
- } |
|
293 |
- } |
|
294 |
- |
|
295 |
- for (var groupKey in triggeredGroups) { |
|
296 |
- triggeredGroups[groupKey].flushTriggers() |
|
297 |
- } |
|
298 |
- |
|
299 |
- this.oldScroll = { |
|
300 |
- x: axes.horizontal.newScroll, |
|
301 |
- y: axes.vertical.newScroll |
|
302 |
- } |
|
303 |
- } |
|
304 |
- |
|
305 |
- /* Private */ |
|
306 |
- Context.prototype.innerHeight = function() { |
|
307 |
- /*eslint-disable eqeqeq */ |
|
308 |
- if (this.element == this.element.window) { |
|
309 |
- return Waypoint.viewportHeight() |
|
310 |
- } |
|
311 |
- /*eslint-enable eqeqeq */ |
|
312 |
- return this.adapter.innerHeight() |
|
313 |
- } |
|
314 |
- |
|
315 |
- /* Private */ |
|
316 |
- Context.prototype.remove = function(waypoint) { |
|
317 |
- delete this.waypoints[waypoint.axis][waypoint.key] |
|
318 |
- this.checkEmpty() |
|
319 |
- } |
|
320 |
- |
|
321 |
- /* Private */ |
|
322 |
- Context.prototype.innerWidth = function() { |
|
323 |
- /*eslint-disable eqeqeq */ |
|
324 |
- if (this.element == this.element.window) { |
|
325 |
- return Waypoint.viewportWidth() |
|
326 |
- } |
|
327 |
- /*eslint-enable eqeqeq */ |
|
328 |
- return this.adapter.innerWidth() |
|
329 |
- } |
|
330 |
- |
|
331 |
- /* Public */ |
|
332 |
- /* http://imakewebthings.com/waypoints/api/context-destroy */ |
|
333 |
- Context.prototype.destroy = function() { |
|
334 |
- var allWaypoints = [] |
|
335 |
- for (var axis in this.waypoints) { |
|
336 |
- for (var waypointKey in this.waypoints[axis]) { |
|
337 |
- allWaypoints.push(this.waypoints[axis][waypointKey]) |
|
338 |
- } |
|
339 |
- } |
|
340 |
- for (var i = 0, end = allWaypoints.length; i < end; i++) { |
|
341 |
- allWaypoints[i].destroy() |
|
342 |
- } |
|
343 |
- } |
|
344 |
- |
|
345 |
- /* Public */ |
|
346 |
- /* http://imakewebthings.com/waypoints/api/context-refresh */ |
|
347 |
- Context.prototype.refresh = function() { |
|
348 |
- /*eslint-disable eqeqeq */ |
|
349 |
- var isWindow = this.element == this.element.window |
|
350 |
- /*eslint-enable eqeqeq */ |
|
351 |
- var contextOffset = this.adapter.offset() |
|
352 |
- var triggeredGroups = {} |
|
353 |
- var axes |
|
354 |
- |
|
355 |
- this.handleScroll() |
|
356 |
- axes = { |
|
357 |
- horizontal: { |
|
358 |
- contextOffset: isWindow ? 0 : contextOffset.left, |
|
359 |
- contextScroll: isWindow ? 0 : this.oldScroll.x, |
|
360 |
- contextDimension: this.innerWidth(), |
|
361 |
- oldScroll: this.oldScroll.x, |
|
362 |
- forward: 'right', |
|
363 |
- backward: 'left', |
|
364 |
- offsetProp: 'left' |
|
365 |
- }, |
|
366 |
- vertical: { |
|
367 |
- contextOffset: isWindow ? 0 : contextOffset.top, |
|
368 |
- contextScroll: isWindow ? 0 : this.oldScroll.y, |
|
369 |
- contextDimension: this.innerHeight(), |
|
370 |
- oldScroll: this.oldScroll.y, |
|
371 |
- forward: 'down', |
|
372 |
- backward: 'up', |
|
373 |
- offsetProp: 'top' |
|
374 |
- } |
|
375 |
- } |
|
376 |
- |
|
377 |
- for (var axisKey in axes) { |
|
378 |
- var axis = axes[axisKey] |
|
379 |
- for (var waypointKey in this.waypoints[axisKey]) { |
|
380 |
- var waypoint = this.waypoints[axisKey][waypointKey] |
|
381 |
- var adjustment = waypoint.options.offset |
|
382 |
- var oldTriggerPoint = waypoint.triggerPoint |
|
383 |
- var elementOffset = 0 |
|
384 |
- var freshWaypoint = oldTriggerPoint == null |
|
385 |
- var contextModifier, wasBeforeScroll, nowAfterScroll |
|
386 |
- var triggeredBackward, triggeredForward |
|
387 |
- |
|
388 |
- if (waypoint.element !== waypoint.element.window) { |
|
389 |
- elementOffset = waypoint.adapter.offset()[axis.offsetProp] |
|
390 |
- } |
|
391 |
- |
|
392 |
- if (typeof adjustment === 'function') { |
|
393 |
- adjustment = adjustment.apply(waypoint) |
|
394 |
- } |
|
395 |
- else if (typeof adjustment === 'string') { |
|
396 |
- adjustment = parseFloat(adjustment) |
|
397 |
- if (waypoint.options.offset.indexOf('%') > - 1) { |
|
398 |
- adjustment = Math.ceil(axis.contextDimension * adjustment / 100) |
|
399 |
- } |
|
400 |
- } |
|
401 |
- |
|
402 |
- contextModifier = axis.contextScroll - axis.contextOffset |
|
403 |
- waypoint.triggerPoint = elementOffset + contextModifier - adjustment |
|
404 |
- wasBeforeScroll = oldTriggerPoint < axis.oldScroll |
|
405 |
- nowAfterScroll = waypoint.triggerPoint >= axis.oldScroll |
|
406 |
- triggeredBackward = wasBeforeScroll && nowAfterScroll |
|
407 |
- triggeredForward = !wasBeforeScroll && !nowAfterScroll |
|
408 |
- |
|
409 |
- if (!freshWaypoint && triggeredBackward) { |
|
410 |
- waypoint.queueTrigger(axis.backward) |
|
411 |
- triggeredGroups[waypoint.group.id] = waypoint.group |
|
412 |
- } |
|
413 |
- else if (!freshWaypoint && triggeredForward) { |
|
414 |
- waypoint.queueTrigger(axis.forward) |
|
415 |
- triggeredGroups[waypoint.group.id] = waypoint.group |
|
416 |
- } |
|
417 |
- else if (freshWaypoint && axis.oldScroll >= waypoint.triggerPoint) { |
|
418 |
- waypoint.queueTrigger(axis.forward) |
|
419 |
- triggeredGroups[waypoint.group.id] = waypoint.group |
|
420 |
- } |
|
421 |
- } |
|
422 |
- } |
|
423 |
- |
|
424 |
- for (var groupKey in triggeredGroups) { |
|
425 |
- triggeredGroups[groupKey].flushTriggers() |
|
426 |
- } |
|
427 |
- |
|
428 |
- return this |
|
429 |
- } |
|
430 |
- |
|
431 |
- /* Private */ |
|
432 |
- Context.findOrCreateByElement = function(element) { |
|
433 |
- return Context.findByElement(element) || new Context(element) |
|
434 |
- } |
|
435 |
- |
|
436 |
- /* Private */ |
|
437 |
- Context.refreshAll = function() { |
|
438 |
- for (var contextId in contexts) { |
|
439 |
- contexts[contextId].refresh() |
|
440 |
- } |
|
441 |
- } |
|
442 |
- |
|
443 |
- /* Public */ |
|
444 |
- /* http://imakewebthings.com/waypoints/api/context-find-by-element */ |
|
445 |
- Context.findByElement = function(element) { |
|
446 |
- return contexts[element.waypointContextKey] |
|
447 |
- } |
|
448 |
- |
|
449 |
- window.onload = function() { |
|
450 |
- if (oldWindowLoad) { |
|
451 |
- oldWindowLoad() |
|
452 |
- } |
|
453 |
- Context.refreshAll() |
|
454 |
- } |
|
455 |
- |
|
456 |
- Waypoint.requestAnimationFrame = function(callback) { |
|
457 |
- var requestFn = window.requestAnimationFrame || |
|
458 |
- window.mozRequestAnimationFrame || |
|
459 |
- window.webkitRequestAnimationFrame || |
|
460 |
- requestAnimationFrameShim |
|
461 |
- requestFn.call(window, callback) |
|
462 |
- } |
|
463 |
- Waypoint.Context = Context |
|
464 |
-}()) |
|
465 |
-;(function() { |
|
466 |
- 'use strict' |
|
467 |
- |
|
468 |
- function byTriggerPoint(a, b) { |
|
469 |
- return a.triggerPoint - b.triggerPoint |
|
470 |
- } |
|
471 |
- |
|
472 |
- function byReverseTriggerPoint(a, b) { |
|
473 |
- return b.triggerPoint - a.triggerPoint |
|
474 |
- } |
|
475 |
- |
|
476 |
- var groups = { |
|
477 |
- vertical: {}, |
|
478 |
- horizontal: {} |
|
479 |
- } |
|
480 |
- var Waypoint = window.Waypoint |
|
481 |
- |
|
482 |
- /* http://imakewebthings.com/waypoints/api/group */ |
|
483 |
- function Group(options) { |
|
484 |
- this.name = options.name |
|
485 |
- this.axis = options.axis |
|
486 |
- this.id = this.name + '-' + this.axis |
|
487 |
- this.waypoints = [] |
|
488 |
- this.clearTriggerQueues() |
|
489 |
- groups[this.axis][this.name] = this |
|
490 |
- } |
|
491 |
- |
|
492 |
- /* Private */ |
|
493 |
- Group.prototype.add = function(waypoint) { |
|
494 |
- this.waypoints.push(waypoint) |
|
495 |
- } |
|
496 |
- |
|
497 |
- /* Private */ |
|
498 |
- Group.prototype.clearTriggerQueues = function() { |
|
499 |
- this.triggerQueues = { |
|
500 |
- up: [], |
|
501 |
- down: [], |
|
502 |
- left: [], |
|
503 |
- right: [] |
|
504 |
- } |
|
505 |
- } |
|
506 |
- |
|
507 |
- /* Private */ |
|
508 |
- Group.prototype.flushTriggers = function() { |
|
509 |
- for (var direction in this.triggerQueues) { |
|
510 |
- var waypoints = this.triggerQueues[direction] |
|
511 |
- var reverse = direction === 'up' || direction === 'left' |
|
512 |
- waypoints.sort(reverse ? byReverseTriggerPoint : byTriggerPoint) |
|
513 |
- for (var i = 0, end = waypoints.length; i < end; i += 1) { |
|
514 |
- var waypoint = waypoints[i] |
|
515 |
- if (waypoint.options.continuous || i === waypoints.length - 1) { |
|
516 |
- waypoint.trigger([direction]) |
|
517 |
- } |
|
518 |
- } |
|
519 |
- } |
|
520 |
- this.clearTriggerQueues() |
|
521 |
- } |
|
522 |
- |
|
523 |
- /* Private */ |
|
524 |
- Group.prototype.next = function(waypoint) { |
|
525 |
- this.waypoints.sort(byTriggerPoint) |
|
526 |
- var index = Waypoint.Adapter.inArray(waypoint, this.waypoints) |
|
527 |
- var isLast = index === this.waypoints.length - 1 |
|
528 |
- return isLast ? null : this.waypoints[index + 1] |
|
529 |
- } |
|
530 |
- |
|
531 |
- /* Private */ |
|
532 |
- Group.prototype.previous = function(waypoint) { |
|
533 |
- this.waypoints.sort(byTriggerPoint) |
|
534 |
- var index = Waypoint.Adapter.inArray(waypoint, this.waypoints) |
|
535 |
- return index ? this.waypoints[index - 1] : null |
|
536 |
- } |
|
537 |
- |
|
538 |
- /* Private */ |
|
539 |
- Group.prototype.queueTrigger = function(waypoint, direction) { |
|
540 |
- this.triggerQueues[direction].push(waypoint) |
|
541 |
- } |
|
542 |
- |
|
543 |
- /* Private */ |
|
544 |
- Group.prototype.remove = function(waypoint) { |
|
545 |
- var index = Waypoint.Adapter.inArray(waypoint, this.waypoints) |
|
546 |
- if (index > -1) { |
|
547 |
- this.waypoints.splice(index, 1) |
|
548 |
- } |
|
549 |
- } |
|
550 |
- |
|
551 |
- /* Public */ |
|
552 |
- /* http://imakewebthings.com/waypoints/api/first */ |
|
553 |
- Group.prototype.first = function() { |
|
554 |
- return this.waypoints[0] |
|
555 |
- } |
|
556 |
- |
|
557 |
- /* Public */ |
|
558 |
- /* http://imakewebthings.com/waypoints/api/last */ |
|
559 |
- Group.prototype.last = function() { |
|
560 |
- return this.waypoints[this.waypoints.length - 1] |
|
561 |
- } |
|
562 |
- |
|
563 |
- /* Private */ |
|
564 |
- Group.findOrCreate = function(options) { |
|
565 |
- return groups[options.axis][options.name] || new Group(options) |
|
566 |
- } |
|
567 |
- |
|
568 |
- Waypoint.Group = Group |
|
569 |
-}()) |
|
570 |
-;(function() { |
|
571 |
- 'use strict' |
|
572 |
- |
|
573 |
- var $ = window.jQuery |
|
574 |
- var Waypoint = window.Waypoint |
|
575 |
- |
|
576 |
- function JQueryAdapter(element) { |
|
577 |
- this.$element = $(element) |
|
578 |
- } |
|
579 |
- |
|
580 |
- $.each([ |
|
581 |
- 'innerHeight', |
|
582 |
- 'innerWidth', |
|
583 |
- 'off', |
|
584 |
- 'offset', |
|
585 |
- 'on', |
|
586 |
- 'outerHeight', |
|
587 |
- 'outerWidth', |
|
588 |
- 'scrollLeft', |
|
589 |
- 'scrollTop' |
|
590 |
- ], function(i, method) { |
|
591 |
- JQueryAdapter.prototype[method] = function() { |
|
592 |
- var args = Array.prototype.slice.call(arguments) |
|
593 |
- return this.$element[method].apply(this.$element, args) |
|
594 |
- } |
|
595 |
- }) |
|
596 |
- |
|
597 |
- $.each([ |
|
598 |
- 'extend', |
|
599 |
- 'inArray', |
|
600 |
- 'isEmptyObject' |
|
601 |
- ], function(i, method) { |
|
602 |
- JQueryAdapter[method] = $[method] |
|
603 |
- }) |
|
604 |
- |
|
605 |
- Waypoint.adapters.push({ |
|
606 |
- name: 'jquery', |
|
607 |
- Adapter: JQueryAdapter |
|
608 |
- }) |
|
609 |
- Waypoint.Adapter = JQueryAdapter |
|
610 |
-}()) |
|
611 |
-;(function() { |
|
612 |
- 'use strict' |
|
613 |
- |
|
614 |
- var Waypoint = window.Waypoint |
|
615 |
- |
|
616 |
- function createExtension(framework) { |
|
617 |
- return function() { |
|
618 |
- var waypoints = [] |
|
619 |
- var overrides = arguments[0] |
|
620 |
- |
|
621 |
- if (framework.isFunction(arguments[0])) { |
|
622 |
- overrides = framework.extend({}, arguments[1]) |
|
623 |
- overrides.handler = arguments[0] |
|
624 |
- } |
|
625 |
- |
|
626 |
- this.each(function() { |
|
627 |
- var options = framework.extend({}, overrides, { |
|
628 |
- element: this |
|
629 |
- }) |
|
630 |
- if (typeof options.context === 'string') { |
|
631 |
- options.context = framework(this).closest(options.context)[0] |
|
632 |
- } |
|
633 |
- waypoints.push(new Waypoint(options)) |
|
634 |
- }) |
|
635 |
- |
|
636 |
- return waypoints |
|
637 |
- } |
|
638 |
- } |
|
639 |
- |
|
640 |
- if (window.jQuery) { |
|
641 |
- window.jQuery.fn.waypoint = createExtension(window.jQuery) |
|
642 |
- } |
|
643 |
- if (window.Zepto) { |
|
644 |
- window.Zepto.fn.waypoint = createExtension(window.Zepto) |
|
645 |
- } |
|
646 |
-}()) |
|
647 |
-; |
|
648 | 0 |
\ No newline at end of file |
649 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,7 +0,0 @@ |
1 |
-/*! |
|
2 |
-Waypoints - 3.1.1 |
|
3 |
-Copyright © 2011-2015 Caleb Troughton |
|
4 |
-Licensed under the MIT license. |
|
5 |
-https://github.com/imakewebthings/waypoints/blog/master/licenses.txt |
|
6 |
-*/ |
|
7 |
-!function(){"use strict";function t(o){if(!o)throw new Error("No options passed to Waypoint constructor");if(!o.element)throw new Error("No element option passed to Waypoint constructor");if(!o.handler)throw new Error("No handler option passed to Waypoint constructor");this.key="waypoint-"+e,this.options=t.Adapter.extend({},t.defaults,o),this.element=this.options.element,this.adapter=new t.Adapter(this.element),this.callback=o.handler,this.axis=this.options.horizontal?"horizontal":"vertical",this.enabled=this.options.enabled,this.triggerPoint=null,this.group=t.Group.findOrCreate({name:this.options.group,axis:this.axis}),this.context=t.Context.findOrCreateByElement(this.options.context),t.offsetAliases[this.options.offset]&&(this.options.offset=t.offsetAliases[this.options.offset]),this.group.add(this),this.context.add(this),i[this.key]=this,e+=1}var e=0,i={};t.prototype.queueTrigger=function(t){this.group.queueTrigger(this,t)},t.prototype.trigger=function(t){this.enabled&&this.callback&&this.callback.apply(this,t)},t.prototype.destroy=function(){this.context.remove(this),this.group.remove(this),delete i[this.key]},t.prototype.disable=function(){return this.enabled=!1,this},t.prototype.enable=function(){return this.context.refresh(),this.enabled=!0,this},t.prototype.next=function(){return this.group.next(this)},t.prototype.previous=function(){return this.group.previous(this)},t.invokeAll=function(t){var e=[];for(var o in i)e.push(i[o]);for(var n=0,r=e.length;r>n;n++)e[n][t]()},t.destroyAll=function(){t.invokeAll("destroy")},t.disableAll=function(){t.invokeAll("disable")},t.enableAll=function(){t.invokeAll("enable")},t.refreshAll=function(){t.Context.refreshAll()},t.viewportHeight=function(){return window.innerHeight||document.documentElement.clientHeight},t.viewportWidth=function(){return document.documentElement.clientWidth},t.adapters=[],t.defaults={context:window,continuous:!0,enabled:!0,group:"default",horizontal:!1,offset:0},t.offsetAliases={"bottom-in-view":function(){return this.context.innerHeight()-this.adapter.outerHeight()},"right-in-view":function(){return this.context.innerWidth()-this.adapter.outerWidth()}},window.Waypoint=t}(),function(){"use strict";function t(t){window.setTimeout(t,1e3/60)}function e(t){this.element=t,this.Adapter=n.Adapter,this.adapter=new this.Adapter(t),this.key="waypoint-context-"+i,this.didScroll=!1,this.didResize=!1,this.oldScroll={x:this.adapter.scrollLeft(),y:this.adapter.scrollTop()},this.waypoints={vertical:{},horizontal:{}},t.waypointContextKey=this.key,o[t.waypointContextKey]=this,i+=1,this.createThrottledScrollHandler(),this.createThrottledResizeHandler()}var i=0,o={},n=window.Waypoint,r=window.onload;e.prototype.add=function(t){var e=t.options.horizontal?"horizontal":"vertical";this.waypoints[e][t.key]=t,this.refresh()},e.prototype.checkEmpty=function(){var t=this.Adapter.isEmptyObject(this.waypoints.horizontal),e=this.Adapter.isEmptyObject(this.waypoints.vertical);t&&e&&(this.adapter.off(".waypoints"),delete o[this.key])},e.prototype.createThrottledResizeHandler=function(){function t(){e.handleResize(),e.didResize=!1}var e=this;this.adapter.on("resize.waypoints",function(){e.didResize||(e.didResize=!0,n.requestAnimationFrame(t))})},e.prototype.createThrottledScrollHandler=function(){function t(){e.handleScroll(),e.didScroll=!1}var e=this;this.adapter.on("scroll.waypoints",function(){(!e.didScroll||n.isTouch)&&(e.didScroll=!0,n.requestAnimationFrame(t))})},e.prototype.handleResize=function(){n.Context.refreshAll()},e.prototype.handleScroll=function(){var t={},e={horizontal:{newScroll:this.adapter.scrollLeft(),oldScroll:this.oldScroll.x,forward:"right",backward:"left"},vertical:{newScroll:this.adapter.scrollTop(),oldScroll:this.oldScroll.y,forward:"down",backward:"up"}};for(var i in e){var o=e[i],n=o.newScroll>o.oldScroll,r=n?o.forward:o.backward;for(var s in this.waypoints[i]){var a=this.waypoints[i][s],l=o.oldScroll<a.triggerPoint,h=o.newScroll>=a.triggerPoint,p=l&&h,u=!l&&!h;(p||u)&&(a.queueTrigger(r),t[a.group.id]=a.group)}}for(var c in t)t[c].flushTriggers();this.oldScroll={x:e.horizontal.newScroll,y:e.vertical.newScroll}},e.prototype.innerHeight=function(){return this.element==this.element.window?n.viewportHeight():this.adapter.innerHeight()},e.prototype.remove=function(t){delete this.waypoints[t.axis][t.key],this.checkEmpty()},e.prototype.innerWidth=function(){return this.element==this.element.window?n.viewportWidth():this.adapter.innerWidth()},e.prototype.destroy=function(){var t=[];for(var e in this.waypoints)for(var i in this.waypoints[e])t.push(this.waypoints[e][i]);for(var o=0,n=t.length;n>o;o++)t[o].destroy()},e.prototype.refresh=function(){var t,e=this.element==this.element.window,i=this.adapter.offset(),o={};this.handleScroll(),t={horizontal:{contextOffset:e?0:i.left,contextScroll:e?0:this.oldScroll.x,contextDimension:this.innerWidth(),oldScroll:this.oldScroll.x,forward:"right",backward:"left",offsetProp:"left"},vertical:{contextOffset:e?0:i.top,contextScroll:e?0:this.oldScroll.y,contextDimension:this.innerHeight(),oldScroll:this.oldScroll.y,forward:"down",backward:"up",offsetProp:"top"}};for(var n in t){var r=t[n];for(var s in this.waypoints[n]){var a,l,h,p,u,c=this.waypoints[n][s],d=c.options.offset,f=c.triggerPoint,w=0,y=null==f;c.element!==c.element.window&&(w=c.adapter.offset()[r.offsetProp]),"function"==typeof d?d=d.apply(c):"string"==typeof d&&(d=parseFloat(d),c.options.offset.indexOf("%")>-1&&(d=Math.ceil(r.contextDimension*d/100))),a=r.contextScroll-r.contextOffset,c.triggerPoint=w+a-d,l=f<r.oldScroll,h=c.triggerPoint>=r.oldScroll,p=l&&h,u=!l&&!h,!y&&p?(c.queueTrigger(r.backward),o[c.group.id]=c.group):!y&&u?(c.queueTrigger(r.forward),o[c.group.id]=c.group):y&&r.oldScroll>=c.triggerPoint&&(c.queueTrigger(r.forward),o[c.group.id]=c.group)}}for(var g in o)o[g].flushTriggers();return this},e.findOrCreateByElement=function(t){return e.findByElement(t)||new e(t)},e.refreshAll=function(){for(var t in o)o[t].refresh()},e.findByElement=function(t){return o[t.waypointContextKey]},window.onload=function(){r&&r(),e.refreshAll()},n.requestAnimationFrame=function(e){var i=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||t;i.call(window,e)},n.Context=e}(),function(){"use strict";function t(t,e){return t.triggerPoint-e.triggerPoint}function e(t,e){return e.triggerPoint-t.triggerPoint}function i(t){this.name=t.name,this.axis=t.axis,this.id=this.name+"-"+this.axis,this.waypoints=[],this.clearTriggerQueues(),o[this.axis][this.name]=this}var o={vertical:{},horizontal:{}},n=window.Waypoint;i.prototype.add=function(t){this.waypoints.push(t)},i.prototype.clearTriggerQueues=function(){this.triggerQueues={up:[],down:[],left:[],right:[]}},i.prototype.flushTriggers=function(){for(var i in this.triggerQueues){var o=this.triggerQueues[i],n="up"===i||"left"===i;o.sort(n?e:t);for(var r=0,s=o.length;s>r;r+=1){var a=o[r];(a.options.continuous||r===o.length-1)&&a.trigger([i])}}this.clearTriggerQueues()},i.prototype.next=function(e){this.waypoints.sort(t);var i=n.Adapter.inArray(e,this.waypoints),o=i===this.waypoints.length-1;return o?null:this.waypoints[i+1]},i.prototype.previous=function(e){this.waypoints.sort(t);var i=n.Adapter.inArray(e,this.waypoints);return i?this.waypoints[i-1]:null},i.prototype.queueTrigger=function(t,e){this.triggerQueues[e].push(t)},i.prototype.remove=function(t){var e=n.Adapter.inArray(t,this.waypoints);e>-1&&this.waypoints.splice(e,1)},i.prototype.first=function(){return this.waypoints[0]},i.prototype.last=function(){return this.waypoints[this.waypoints.length-1]},i.findOrCreate=function(t){return o[t.axis][t.name]||new i(t)},n.Group=i}(),function(){"use strict";function t(t){this.$element=e(t)}var e=window.jQuery,i=window.Waypoint;e.each(["innerHeight","innerWidth","off","offset","on","outerHeight","outerWidth","scrollLeft","scrollTop"],function(e,i){t.prototype[i]=function(){var t=Array.prototype.slice.call(arguments);return this.$element[i].apply(this.$element,t)}}),e.each(["extend","inArray","isEmptyObject"],function(i,o){t[o]=e[o]}),i.adapters.push({name:"jquery",Adapter:t}),i.Adapter=t}(),function(){"use strict";function t(t){return function(){var i=[],o=arguments[0];return t.isFunction(arguments[0])&&(o=t.extend({},arguments[1]),o.handler=arguments[0]),this.each(function(){var n=t.extend({},o,{element:this});"string"==typeof n.context&&(n.context=t(this).closest(n.context)[0]),i.push(new e(n))}),i}}var e=window.Waypoint;window.jQuery&&(window.jQuery.fn.waypoint=t(window.jQuery)),window.Zepto&&(window.Zepto.fn.waypoint=t(window.Zepto))}(); |
|
8 | 0 |
\ No newline at end of file |
9 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,84 +0,0 @@ |
1 |
-/*! |
|
2 |
-Waypoints Infinite Scroll Shortcut - 3.1.1 |
|
3 |
-Copyright © 2011-2015 Caleb Troughton |
|
4 |
-Licensed under the MIT license. |
|
5 |
-https://github.com/imakewebthings/waypoints/blog/master/licenses.txt |
|
6 |
-*/ |
|
7 |
-(function() { |
|
8 |
- 'use strict' |
|
9 |
- |
|
10 |
- var $ = window.jQuery |
|
11 |
- var Waypoint = window.Waypoint |
|
12 |
- |
|
13 |
- /* http://imakewebthings.com/waypoints/shortcuts/infinite-scroll */ |
|
14 |
- function Infinite(options) { |
|
15 |
- this.options = $.extend({}, Infinite.defaults, options) |
|
16 |
- this.container = this.options.element |
|
17 |
- if (this.options.container !== 'auto') { |
|
18 |
- this.container = this.options.container |
|
19 |
- } |
|
20 |
- this.$container = $(this.container) |
|
21 |
- this.$more = $(this.options.more) |
|
22 |
- |
|
23 |
- if (this.$more.length) { |
|
24 |
- this.setupHandler() |
|
25 |
- this.waypoint = new Waypoint(this.options) |
|
26 |
- } |
|
27 |
- } |
|
28 |
- |
|
29 |
- /* Private */ |
|
30 |
- Infinite.prototype.setupHandler = function() { |
|
31 |
- this.options.handler = $.proxy(function() { |
|
32 |
- this.options.onBeforePageLoad() |
|
33 |
- this.destroy() |
|
34 |
- this.$container.addClass(this.options.loadingClass) |
|
35 |
- |
|
36 |
- $.get($(this.options.more).attr('href'), $.proxy(function(data) { |
|
37 |
- var $data = $($.parseHTML(data)) |
|
38 |
- var $newMore = $data.find(this.options.more) |
|
39 |
- |
|
40 |
- var $items = $data.find(this.options.items) |
|
41 |
- if (!$items.length) { |
|
42 |
- $items = $data.filter(this.options.items) |
|
43 |
- } |
|
44 |
- |
|
45 |
- this.$container.append($items) |
|
46 |
- this.$container.removeClass(this.options.loadingClass) |
|
47 |
- |
|
48 |
- if (!$newMore.length) { |
|
49 |
- $newMore = $data.filter(this.options.more) |
|
50 |
- } |
|
51 |
- if ($newMore.length) { |
|
52 |
- this.$more.replaceWith($newMore) |
|
53 |
- this.$more = $newMore |
|
54 |
- this.waypoint = new Waypoint(this.options) |
|
55 |
- } |
|
56 |
- else { |
|
57 |
- this.$more.remove() |
|
58 |
- } |
|
59 |
- |
|
60 |
- this.options.onAfterPageLoad() |
|
61 |
- }, this)) |
|
62 |
- }, this) |
|
63 |
- } |
|
64 |
- |
|
65 |
- /* Public */ |
|
66 |
- Infinite.prototype.destroy = function() { |
|
67 |
- if (this.waypoint) { |
|
68 |
- this.waypoint.destroy() |
|
69 |
- } |
|
70 |
- } |
|
71 |
- |
|
72 |
- Infinite.defaults = { |
|
73 |
- container: 'auto', |
|
74 |
- items: '.infinite-item', |
|
75 |
- more: '.infinite-more-link', |
|
76 |
- offset: 'bottom-in-view', |
|
77 |
- loadingClass: 'infinite-loading', |
|
78 |
- onBeforePageLoad: $.noop, |
|
79 |
- onAfterPageLoad: $.noop |
|
80 |
- } |
|
81 |
- |
|
82 |
- Waypoint.Infinite = Infinite |
|
83 |
-}()) |
|
84 |
-; |
|
85 | 0 |
\ No newline at end of file |
86 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,7 +0,0 @@ |
1 |
-/*! |
|
2 |
-Waypoints Infinite Scroll Shortcut - 3.1.1 |
|
3 |
-Copyright © 2011-2015 Caleb Troughton |
|
4 |
-Licensed under the MIT license. |
|
5 |
-https://github.com/imakewebthings/waypoints/blog/master/licenses.txt |
|
6 |
-*/ |
|
7 |
-!function(){"use strict";function t(n){this.options=i.extend({},t.defaults,n),this.container=this.options.element,"auto"!==this.options.container&&(this.container=this.options.container),this.$container=i(this.container),this.$more=i(this.options.more),this.$more.length&&(this.setupHandler(),this.waypoint=new o(this.options))}var i=window.jQuery,o=window.Waypoint;t.prototype.setupHandler=function(){this.options.handler=i.proxy(function(){this.options.onBeforePageLoad(),this.destroy(),this.$container.addClass(this.options.loadingClass),i.get(i(this.options.more).attr("href"),i.proxy(function(t){var n=i(i.parseHTML(t)),e=n.find(this.options.more),s=n.find(this.options.items);s.length||(s=n.filter(this.options.items)),this.$container.append(s),this.$container.removeClass(this.options.loadingClass),e.length||(e=n.filter(this.options.more)),e.length?(this.$more.replaceWith(e),this.$more=e,this.waypoint=new o(this.options)):this.$more.remove(),this.options.onAfterPageLoad()},this))},this)},t.prototype.destroy=function(){this.waypoint&&this.waypoint.destroy()},t.defaults={container:"auto",items:".infinite-item",more:".infinite-more-link",offset:"bottom-in-view",loadingClass:"infinite-loading",onBeforePageLoad:i.noop,onAfterPageLoad:i.noop},o.Infinite=t}(); |
|
8 | 0 |
\ No newline at end of file |
9 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,103 +0,0 @@ |
1 |
-/*! |
|
2 |
-Waypoints Inview Shortcut - 3.1.1 |
|
3 |
-Copyright © 2011-2015 Caleb Troughton |
|
4 |
-Licensed under the MIT license. |
|
5 |
-https://github.com/imakewebthings/waypoints/blog/master/licenses.txt |
|
6 |
-*/ |
|
7 |
-(function() { |
|
8 |
- 'use strict' |
|
9 |
- |
|
10 |
- function noop() {} |
|
11 |
- |
|
12 |
- var Waypoint = window.Waypoint |
|
13 |
- |
|
14 |
- /* http://imakewebthings.com/waypoints/shortcuts/inview */ |
|
15 |
- function Inview(options) { |
|
16 |
- this.options = Waypoint.Adapter.extend({}, Inview.defaults, options) |
|
17 |
- this.axis = this.options.horizontal ? 'horizontal' : 'vertical' |
|
18 |
- this.waypoints = [] |
|
19 |
- this.createWaypoints() |
|
20 |
- } |
|
21 |
- |
|
22 |
- /* Private */ |
|
23 |
- Inview.prototype.createWaypoints = function() { |
|
24 |
- var configs = { |
|
25 |
- vertical: [{ |
|
26 |
- down: 'enter', |
|
27 |
- up: 'exited', |
|
28 |
- offset: '100%' |
|
29 |
- }, { |
|
30 |
- down: 'entered', |
|
31 |
- up: 'exit', |
|
32 |
- offset: 'bottom-in-view' |
|
33 |
- }, { |
|
34 |
- down: 'exit', |
|
35 |
- up: 'entered', |
|
36 |
- offset: 0 |
|
37 |
- }, { |
|
38 |
- down: 'exited', |
|
39 |
- up: 'enter', |
|
40 |
- offset: function() { |
|
41 |
- return -this.adapter.outerHeight() |
|
42 |
- } |
|
43 |
- }], |
|
44 |
- horizontal: [{ |
|
45 |
- right: 'enter', |
|
46 |
- left: 'exited', |
|
47 |
- offset: '100%' |
|
48 |
- }, { |
|
49 |
- right: 'entered', |
|
50 |
- left: 'exit', |
|
51 |
- offset: 'right-in-view' |
|
52 |
- }, { |
|
53 |
- right: 'exit', |
|
54 |
- left: 'entered', |
|
55 |
- offset: 0 |
|
56 |
- }, { |
|
57 |
- right: 'exited', |
|
58 |
- left: 'enter', |
|
59 |
- offset: function() { |
|
60 |
- return -this.adapter.outerWidth() |
|
61 |
- } |
|
62 |
- }] |
|
63 |
- } |
|
64 |
- |
|
65 |
- for (var i = 0, end = configs[this.axis].length; i < end; i++) { |
|
66 |
- var config = configs[this.axis][i] |
|
67 |
- this.createWaypoint(config) |
|
68 |
- } |
|
69 |
- } |
|
70 |
- |
|
71 |
- /* Private */ |
|
72 |
- Inview.prototype.createWaypoint = function(config) { |
|
73 |
- var self = this |
|
74 |
- this.waypoints.push(new Waypoint({ |
|
75 |
- element: this.options.element, |
|
76 |
- handler: (function(config) { |
|
77 |
- return function(direction) { |
|
78 |
- self.options[config[direction]].call(this, direction) |
|
79 |
- } |
|
80 |
- }(config)), |
|
81 |
- offset: config.offset, |
|
82 |
- horizontal: this.options.horizontal |
|
83 |
- })) |
|
84 |
- } |
|
85 |
- |
|
86 |
- /* Public */ |
|
87 |
- Inview.prototype.destroy = function() { |
|
88 |
- for (var i = 0, end = this.waypoints.length; i < end; i++) { |
|
89 |
- this.waypoints[i].destroy() |
|
90 |
- } |
|
91 |
- this.waypoints = [] |
|
92 |
- } |
|
93 |
- |
|
94 |
- Inview.defaults = { |
|
95 |
- enter: noop, |
|
96 |
- entered: noop, |
|
97 |
- exit: noop, |
|
98 |
- exited: noop |
|
99 |
- } |
|
100 |
- |
|
101 |
- Waypoint.Inview = Inview |
|
102 |
-}()) |
|
103 |
-; |
|
104 | 0 |
\ No newline at end of file |
105 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,7 +0,0 @@ |
1 |
-/*! |
|
2 |
-Waypoints Inview Shortcut - 3.1.1 |
|
3 |
-Copyright © 2011-2015 Caleb Troughton |
|
4 |
-Licensed under the MIT license. |
|
5 |
-https://github.com/imakewebthings/waypoints/blog/master/licenses.txt |
|
6 |
-*/ |
|
7 |
-!function(){"use strict";function t(){}function e(t){this.options=i.Adapter.extend({},e.defaults,t),this.axis=this.options.horizontal?"horizontal":"vertical",this.waypoints=[],this.createWaypoints()}var i=window.Waypoint;e.prototype.createWaypoints=function(){for(var t={vertical:[{down:"enter",up:"exited",offset:"100%"},{down:"entered",up:"exit",offset:"bottom-in-view"},{down:"exit",up:"entered",offset:0},{down:"exited",up:"enter",offset:function(){return-this.adapter.outerHeight()}}],horizontal:[{right:"enter",left:"exited",offset:"100%"},{right:"entered",left:"exit",offset:"right-in-view"},{right:"exit",left:"entered",offset:0},{right:"exited",left:"enter",offset:function(){return-this.adapter.outerWidth()}}]},e=0,i=t[this.axis].length;i>e;e++){var o=t[this.axis][e];this.createWaypoint(o)}},e.prototype.createWaypoint=function(t){var e=this;this.waypoints.push(new i({element:this.options.element,handler:function(t){return function(i){e.options[t[i]].call(this,i)}}(t),offset:t.offset,horizontal:this.options.horizontal}))},e.prototype.destroy=function(){for(var t=0,e=this.waypoints.length;e>t;t++)this.waypoints[t].destroy();this.waypoints=[]},e.defaults={enter:t,entered:t,exit:t,exited:t},i.Inview=e}(); |
|
8 | 0 |
\ No newline at end of file |
9 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,65 +0,0 @@ |
1 |
-/*! |
|
2 |
-Waypoints Sticky Element Shortcut - 3.1.1 |
|
3 |
-Copyright © 2011-2015 Caleb Troughton |
|
4 |
-Licensed under the MIT license. |
|
5 |
-https://github.com/imakewebthings/waypoints/blog/master/licenses.txt |
|
6 |
-*/ |
|
7 |
-(function() { |
|
8 |
- 'use strict' |
|
9 |
- |
|
10 |
- var $ = window.jQuery |
|
11 |
- var Waypoint = window.Waypoint |
|
12 |
- |
|
13 |
- /* http://imakewebthings.com/waypoints/shortcuts/sticky-elements */ |
|
14 |
- function Sticky(options) { |
|
15 |
- this.options = $.extend({}, Waypoint.defaults, Sticky.defaults, options) |
|
16 |
- this.element = this.options.element |
|
17 |
- this.$element = $(this.element) |
|
18 |
- this.createWrapper() |
|
19 |
- this.createWaypoint() |
|
20 |
- } |
|
21 |
- |
|
22 |
- /* Private */ |
|
23 |
- Sticky.prototype.createWaypoint = function() { |
|
24 |
- var originalHandler = this.options.handler |
|
25 |
- |
|
26 |
- this.waypoint = new Waypoint($.extend({}, this.options, { |
|
27 |
- element: this.wrapper, |
|
28 |
- handler: $.proxy(function(direction) { |
|
29 |
- var shouldBeStuck = this.options.direction.indexOf(direction) > -1 |
|
30 |
- var wrapperHeight = shouldBeStuck ? this.$element.outerHeight(true) : '' |
|
31 |
- |
|
32 |
- this.$wrapper.height(wrapperHeight) |
|
33 |
- this.$element.toggleClass(this.options.stuckClass, shouldBeStuck) |
|
34 |
- |
|
35 |
- if (originalHandler) { |
|
36 |
- originalHandler.call(this, direction) |
|
37 |
- } |
|
38 |
- }, this) |
|
39 |
- })) |
|
40 |
- } |
|
41 |
- |
|
42 |
- /* Private */ |
|
43 |
- Sticky.prototype.createWrapper = function() { |
|
44 |
- this.$element.wrap(this.options.wrapper) |
|
45 |
- this.$wrapper = this.$element.parent() |
|
46 |
- this.wrapper = this.$wrapper[0] |
|
47 |
- } |
|
48 |
- |
|
49 |
- /* Public */ |
|
50 |
- Sticky.prototype.destroy = function() { |
|
51 |
- if (this.$element.parent()[0] === this.wrapper) { |
|
52 |
- this.waypoint.destroy() |
|
53 |
- this.$element.removeClass(this.options.stuckClass).unwrap() |
|
54 |
- } |
|
55 |
- } |
|
56 |
- |
|
57 |
- Sticky.defaults = { |
|
58 |
- wrapper: '<div class="sticky-wrapper" />', |
|
59 |
- stuckClass: 'stuck', |
|
60 |
- direction: 'down right' |
|
61 |
- } |
|
62 |
- |
|
63 |
- Waypoint.Sticky = Sticky |
|
64 |
-}()) |
|
65 |
-; |
|
66 | 0 |
\ No newline at end of file |
67 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,7 +0,0 @@ |
1 |
-/*! |
|
2 |
-Waypoints Sticky Element Shortcut - 3.1.1 |
|
3 |
-Copyright © 2011-2015 Caleb Troughton |
|
4 |
-Licensed under the MIT license. |
|
5 |
-https://github.com/imakewebthings/waypoints/blog/master/licenses.txt |
|
6 |
-*/ |
|
7 |
-!function(){"use strict";function t(s){this.options=e.extend({},i.defaults,t.defaults,s),this.element=this.options.element,this.$element=e(this.element),this.createWrapper(),this.createWaypoint()}var e=window.jQuery,i=window.Waypoint;t.prototype.createWaypoint=function(){var t=this.options.handler;this.waypoint=new i(e.extend({},this.options,{element:this.wrapper,handler:e.proxy(function(e){var i=this.options.direction.indexOf(e)>-1,s=i?this.$element.outerHeight(!0):"";this.$wrapper.height(s),this.$element.toggleClass(this.options.stuckClass,i),t&&t.call(this,e)},this)}))},t.prototype.createWrapper=function(){this.$element.wrap(this.options.wrapper),this.$wrapper=this.$element.parent(),this.wrapper=this.$wrapper[0]},t.prototype.destroy=function(){this.$element.parent()[0]===this.wrapper&&(this.waypoint.destroy(),this.$element.removeClass(this.options.stuckClass).unwrap())},t.defaults={wrapper:'<div class="sticky-wrapper" />',stuckClass:"stuck",direction:"down right"},i.Sticky=t}(); |
|
8 | 0 |
\ No newline at end of file |
9 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,46 +0,0 @@ |
1 |
-/*! |
|
2 |
-Waypoints Debug - 3.1.1 |
|
3 |
-Copyright © 2011-2015 Caleb Troughton |
|
4 |
-Licensed under the MIT license. |
|
5 |
-https://github.com/imakewebthings/waypoints/blog/master/licenses.txt |
|
6 |
-*/ |
|
7 |
-(function() { |
|
8 |
- 'use strict' |
|
9 |
- |
|
10 |
- var displayNoneMessage = [ |
|
11 |
- 'You have a Waypoint element with display none. For more information on ', |
|
12 |
- 'why this is a bad idea read ', |
|
13 |
- 'http://imakewebthings.com/waypoints/guides/debugging/#display-none' |
|
14 |
- ].join('') |
|
15 |
- var fixedMessage = [ |
|
16 |
- 'You have a Waypoint element with fixed positioning. For more ', |
|
17 |
- 'information on why this is a bad idea read ', |
|
18 |
- 'http://imakewebthings.com/waypoints/guides/debugging/#fixed-position' |
|
19 |
- ].join('') |
|
20 |
- |
|
21 |
- function checkWaypointStyles() { |
|
22 |
- var originalRefresh = window.Waypoint.Context.prototype.refresh |
|
23 |
- |
|
24 |
- window.Waypoint.Context.prototype.refresh = function() { |
|
25 |
- for (var axis in this.waypoints) { |
|
26 |
- for (var key in this.waypoints[axis]) { |
|
27 |
- var waypoint = this.waypoints[axis][key] |
|
28 |
- var style = window.getComputedStyle(waypoint.element) |
|
29 |
- if (!waypoint.enabled) { |
|
30 |
- continue |
|
31 |
- } |
|
32 |
- if (style && style.display === 'none') { |
|
33 |
- console.error(displayNoneMessage) |
|
34 |
- } |
|
35 |
- if (style && style.position === 'fixed') { |
|
36 |
- console.error(fixedMessage) |
|
37 |
- } |
|
38 |
- } |
|
39 |
- } |
|
40 |
- return originalRefresh.call(this) |
|
41 |
- } |
|
42 |
- } |
|
43 |
- |
|
44 |
- checkWaypointStyles() |
|
45 |
-}()) |
|
46 |
-; |
|
47 | 0 |
\ No newline at end of file |
48 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,23 +0,0 @@ |
1 |
-Copyright (c) 2011-2012 Caleb Troughton |
|
2 |
- |
|
3 |
- |
|
4 |
-The MIT License |
|
5 |
- |
|
6 |
-Permission is hereby granted, free of charge, to any person obtaining a copy |
|
7 |
-of this software and associated documentation files (the "Software"), to deal |
|
8 |
-in the Software without restriction, including without limitation the rights |
|
9 |
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
10 |
-copies of the Software, and to permit persons to whom the Software is |
|
11 |
-furnished to do so, subject to the following conditions: |
|
12 |
- |
|
13 |
-The above copyright notice and this permission notice shall be included in |
|
14 |
-all copies or substantial portions of the Software. |
|
15 |
- |
|
16 |
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
17 |
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
18 |
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
19 |
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
20 |
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
21 |
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
22 |
-THE SOFTWARE. |
|
23 | 0 |
\ No newline at end of file |