1 | 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 |
1 | 1 |
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 |