waypoints_rails 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +22 -0
- data/README.md +44 -0
- data/Rakefile +2 -0
- data/lib/waypoints_rails/version.rb +3 -0
- data/lib/waypoints_rails.rb +9 -0
- data/vendor/assets/javascripts/infinite.js +81 -0
- data/vendor/assets/javascripts/inview.js +103 -0
- data/vendor/assets/javascripts/jquery.waypoints.js +620 -0
- data/vendor/assets/javascripts/sticky.js +65 -0
- data/waypoints_rails.gemspec +23 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 269b2cbdff9e1a753afd49eea624b53434c70d6f
|
4
|
+
data.tar.gz: 37a6f99cdbc15dba424c9e5ddebb2f86e8be3c50
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 47714d99aea2585e8866339e8923954e677caf57ea0b8f2f7ca18d757496d26b009b889b834ee28e8a261e0eddf119257fc4f6df05882b35e00a7962405715ea
|
7
|
+
data.tar.gz: d738309cd3e19103e361055534577074ed604417e72d8d5802064f19527bb81e26101bfc448cb1c7f3ad8a902082e947b94ace8617bec3c3170a8ff319688d95
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Richard Tan
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# waypoints_rails
|
2
|
+
|
3
|
+
Simple asset pipeline management for [Waypoints.js](http://imakewebthings.com/waypoints/)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'waypoints_rails'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install waypoints_rails
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
In your application.js:
|
24
|
+
``` ruby
|
25
|
+
//= require jquery.waypoints
|
26
|
+
```
|
27
|
+
|
28
|
+
And then, for optional waypoints shortcuts, require the following:
|
29
|
+
``` ruby
|
30
|
+
//= require infinite
|
31
|
+
//= require inview
|
32
|
+
//= require sticky
|
33
|
+
```
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
1. Fork it ( https://github.com/[my-github-username]/waypoints_rails/fork )
|
38
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
39
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
40
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
41
|
+
5. Create a new Pull Request
|
42
|
+
|
43
|
+
|
44
|
+
Built by the team at [Nifty](https://www.niftyforms.com/).
|
data/Rakefile
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
/*!
|
2
|
+
Waypoints Infinite Scroll Shortcut - 3.0.0
|
3
|
+
Copyright © 2011-2014 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
|
+
window.setTimeout($.proxy(function() {
|
33
|
+
this.options.onBeforePageLoad()
|
34
|
+
this.destroy()
|
35
|
+
this.$container.addClass(this.options.loadingClass)
|
36
|
+
|
37
|
+
$.get($(this.options.more).attr('href'), $.proxy(function(data) {
|
38
|
+
var $data = $($.parseHTML(data))
|
39
|
+
var $newMore = $data.find(this.options.more)
|
40
|
+
|
41
|
+
this.$container.append($data.find(this.options.items))
|
42
|
+
this.$container.removeClass(this.options.loadingClass)
|
43
|
+
|
44
|
+
if (!$newMore.length) {
|
45
|
+
$newMore = $data.filter(this.options.more)
|
46
|
+
}
|
47
|
+
if ($newMore.length) {
|
48
|
+
this.$more.replaceWith($newMore)
|
49
|
+
this.$more = $newMore
|
50
|
+
this.waypoint = new Waypoint(this.options)
|
51
|
+
}
|
52
|
+
else {
|
53
|
+
this.$more.remove()
|
54
|
+
}
|
55
|
+
|
56
|
+
this.options.onAfterPageLoad()
|
57
|
+
}, this), 0)
|
58
|
+
}, this))
|
59
|
+
}, this)
|
60
|
+
}
|
61
|
+
|
62
|
+
/* Public */
|
63
|
+
Infinite.prototype.destroy = function() {
|
64
|
+
if (this.waypoint) {
|
65
|
+
this.waypoint.destroy()
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
Infinite.defaults = {
|
70
|
+
container: 'auto',
|
71
|
+
items: '.infinite-item',
|
72
|
+
more: '.infinite-more-link',
|
73
|
+
offset: 'bottom-in-view',
|
74
|
+
loadingClass: 'infinite-loading',
|
75
|
+
onBeforePageLoad: $.noop,
|
76
|
+
onAfterPageLoad: $.noop
|
77
|
+
}
|
78
|
+
|
79
|
+
Waypoint.Infinite = Infinite
|
80
|
+
}())
|
81
|
+
;
|
@@ -0,0 +1,103 @@
|
|
1
|
+
/*!
|
2
|
+
Waypoints Inview Shortcut - 3.0.0
|
3
|
+
Copyright © 2011-2014 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,0 +1,620 @@
|
|
1
|
+
/*!
|
2
|
+
Waypoints - 3.0.0
|
3
|
+
Copyright © 2011-2014 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
|
+
/* Public */
|
99
|
+
/* http://imakewebthings.com/waypoints/api/destroy-all */
|
100
|
+
Waypoint.destroyAll = function() {
|
101
|
+
var allWaypointsArray = []
|
102
|
+
for (var waypointKey in allWaypoints) {
|
103
|
+
allWaypointsArray.push(allWaypoints[waypointKey])
|
104
|
+
}
|
105
|
+
for (var i = 0, end = allWaypointsArray.length; i < end; i++) {
|
106
|
+
allWaypointsArray[i].destroy()
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
/* Public */
|
111
|
+
/* http://imakewebthings.com/waypoints/api/refresh-all */
|
112
|
+
Waypoint.refreshAll = function() {
|
113
|
+
Waypoint.Context.refreshAll()
|
114
|
+
}
|
115
|
+
|
116
|
+
/* Public */
|
117
|
+
/* http://imakewebthings.com/waypoints/api/viewport-height */
|
118
|
+
Waypoint.viewportHeight = function() {
|
119
|
+
return window.innerHeight || document.documentElement.clientHeight
|
120
|
+
}
|
121
|
+
|
122
|
+
/* Public */
|
123
|
+
/* http://imakewebthings.com/waypoints/api/viewport-width */
|
124
|
+
Waypoint.viewportWidth = function() {
|
125
|
+
return document.documentElement.clientWidth
|
126
|
+
}
|
127
|
+
|
128
|
+
Waypoint.adapters = []
|
129
|
+
|
130
|
+
Waypoint.defaults = {
|
131
|
+
context: window,
|
132
|
+
continuous: true,
|
133
|
+
enabled: true,
|
134
|
+
group: 'default',
|
135
|
+
horizontal: false,
|
136
|
+
offset: 0
|
137
|
+
}
|
138
|
+
|
139
|
+
Waypoint.offsetAliases = {
|
140
|
+
'bottom-in-view': function() {
|
141
|
+
return this.context.innerHeight() - this.adapter.outerHeight()
|
142
|
+
},
|
143
|
+
'right-in-view': function() {
|
144
|
+
return this.context.innerWidth() - this.adapter.outerWidth()
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
window.Waypoint = Waypoint
|
149
|
+
}())
|
150
|
+
;(function() {
|
151
|
+
'use strict'
|
152
|
+
|
153
|
+
function requestAnimationFrameShim(callback) {
|
154
|
+
window.setTimeout(callback, 1000 / 60)
|
155
|
+
}
|
156
|
+
|
157
|
+
var keyCounter = 0
|
158
|
+
var contexts = {}
|
159
|
+
var Waypoint = window.Waypoint
|
160
|
+
var requestAnimationFrame = window.requestAnimationFrame ||
|
161
|
+
window.mozRequestAnimationFrame ||
|
162
|
+
window.webkitRequestAnimationFrame ||
|
163
|
+
requestAnimationFrameShim
|
164
|
+
var oldWindowLoad = window.onload
|
165
|
+
|
166
|
+
/* http://imakewebthings.com/waypoints/api/context */
|
167
|
+
function Context(element) {
|
168
|
+
this.element = element
|
169
|
+
this.Adapter = Waypoint.Adapter
|
170
|
+
this.adapter = new this.Adapter(element)
|
171
|
+
this.key = 'waypoint-context-' + keyCounter
|
172
|
+
this.didScroll = false
|
173
|
+
this.didResize = false
|
174
|
+
this.oldScroll = {
|
175
|
+
x: this.adapter.scrollLeft(),
|
176
|
+
y: this.adapter.scrollTop()
|
177
|
+
}
|
178
|
+
this.waypoints = {
|
179
|
+
vertical: {},
|
180
|
+
horizontal: {}
|
181
|
+
}
|
182
|
+
|
183
|
+
element.waypointContextKey = this.key
|
184
|
+
contexts[element.waypointContextKey] = this
|
185
|
+
keyCounter += 1
|
186
|
+
|
187
|
+
this.createThrottledScrollHandler()
|
188
|
+
this.createThrottledResizeHandler()
|
189
|
+
}
|
190
|
+
|
191
|
+
/* Private */
|
192
|
+
Context.prototype.add = function(waypoint) {
|
193
|
+
var axis = waypoint.options.horizontal ? 'horizontal' : 'vertical'
|
194
|
+
this.waypoints[axis][waypoint.key] = waypoint
|
195
|
+
this.refresh()
|
196
|
+
}
|
197
|
+
|
198
|
+
/* Private */
|
199
|
+
Context.prototype.checkEmpty = function() {
|
200
|
+
var horizontalEmpty = this.Adapter.isEmptyObject(this.waypoints.horizontal)
|
201
|
+
var verticalEmpty = this.Adapter.isEmptyObject(this.waypoints.vertical)
|
202
|
+
if (horizontalEmpty && verticalEmpty) {
|
203
|
+
this.adapter.off('.waypoints')
|
204
|
+
delete contexts[this.key]
|
205
|
+
}
|
206
|
+
}
|
207
|
+
|
208
|
+
/* Private */
|
209
|
+
Context.prototype.createThrottledResizeHandler = function() {
|
210
|
+
var self = this
|
211
|
+
|
212
|
+
function resizeHandler() {
|
213
|
+
self.handleResize()
|
214
|
+
self.didResize = false
|
215
|
+
}
|
216
|
+
|
217
|
+
this.adapter.on('resize.waypoints', function() {
|
218
|
+
if (!self.didResize) {
|
219
|
+
self.didResize = true
|
220
|
+
requestAnimationFrame(resizeHandler)
|
221
|
+
}
|
222
|
+
})
|
223
|
+
}
|
224
|
+
|
225
|
+
/* Private */
|
226
|
+
Context.prototype.createThrottledScrollHandler = function() {
|
227
|
+
var self = this
|
228
|
+
function scrollHandler() {
|
229
|
+
self.handleScroll()
|
230
|
+
self.didScroll = false
|
231
|
+
}
|
232
|
+
|
233
|
+
this.adapter.on('scroll.waypoints', function() {
|
234
|
+
if (!self.didScroll || Waypoint.isTouch) {
|
235
|
+
self.didScroll = true
|
236
|
+
requestAnimationFrame(scrollHandler)
|
237
|
+
}
|
238
|
+
})
|
239
|
+
}
|
240
|
+
|
241
|
+
/* Private */
|
242
|
+
Context.prototype.handleResize = function() {
|
243
|
+
Waypoint.Context.refreshAll()
|
244
|
+
}
|
245
|
+
|
246
|
+
/* Private */
|
247
|
+
Context.prototype.handleScroll = function() {
|
248
|
+
var triggeredGroups = {}
|
249
|
+
var axes = {
|
250
|
+
horizontal: {
|
251
|
+
newScroll: this.adapter.scrollLeft(),
|
252
|
+
oldScroll: this.oldScroll.x,
|
253
|
+
forward: 'right',
|
254
|
+
backward: 'left'
|
255
|
+
},
|
256
|
+
vertical: {
|
257
|
+
newScroll: this.adapter.scrollTop(),
|
258
|
+
oldScroll: this.oldScroll.y,
|
259
|
+
forward: 'down',
|
260
|
+
backward: 'up'
|
261
|
+
}
|
262
|
+
}
|
263
|
+
|
264
|
+
for (var axisKey in axes) {
|
265
|
+
var axis = axes[axisKey]
|
266
|
+
var isForward = axis.newScroll > axis.oldScroll
|
267
|
+
var direction = isForward ? axis.forward : axis.backward
|
268
|
+
|
269
|
+
for (var waypointKey in this.waypoints[axisKey]) {
|
270
|
+
var waypoint = this.waypoints[axisKey][waypointKey]
|
271
|
+
var wasBeforeTriggerPoint = axis.oldScroll < waypoint.triggerPoint
|
272
|
+
var nowAfterTriggerPoint = axis.newScroll >= waypoint.triggerPoint
|
273
|
+
var crossedForward = wasBeforeTriggerPoint && nowAfterTriggerPoint
|
274
|
+
var crossedBackward = !wasBeforeTriggerPoint && !nowAfterTriggerPoint
|
275
|
+
if (crossedForward || crossedBackward) {
|
276
|
+
waypoint.queueTrigger(direction)
|
277
|
+
triggeredGroups[waypoint.group.id] = waypoint.group
|
278
|
+
}
|
279
|
+
}
|
280
|
+
}
|
281
|
+
|
282
|
+
for (var groupKey in triggeredGroups) {
|
283
|
+
triggeredGroups[groupKey].flushTriggers()
|
284
|
+
}
|
285
|
+
|
286
|
+
this.oldScroll = {
|
287
|
+
x: axes.horizontal.newScroll,
|
288
|
+
y: axes.vertical.newScroll
|
289
|
+
}
|
290
|
+
}
|
291
|
+
|
292
|
+
/* Private */
|
293
|
+
Context.prototype.innerHeight = function() {
|
294
|
+
if (this.element === this.element.window) {
|
295
|
+
return Waypoint.viewportHeight()
|
296
|
+
}
|
297
|
+
return this.adapter.innerHeight()
|
298
|
+
}
|
299
|
+
|
300
|
+
/* Private */
|
301
|
+
Context.prototype.remove = function(waypoint) {
|
302
|
+
delete this.waypoints[waypoint.axis][waypoint.key]
|
303
|
+
this.checkEmpty()
|
304
|
+
}
|
305
|
+
|
306
|
+
/* Private */
|
307
|
+
Context.prototype.innerWidth = function() {
|
308
|
+
if (this.element === this.element.window) {
|
309
|
+
return Waypoint.viewportWidth()
|
310
|
+
}
|
311
|
+
return this.adapter.innerWidth()
|
312
|
+
}
|
313
|
+
|
314
|
+
/* Public */
|
315
|
+
/* http://imakewebthings.com/waypoints/api/context-destroy */
|
316
|
+
Context.prototype.destroy = function() {
|
317
|
+
var allWaypoints = []
|
318
|
+
for (var axis in this.waypoints) {
|
319
|
+
for (var waypointKey in this.waypoints[axis]) {
|
320
|
+
allWaypoints.push(this.waypoints[axis][waypointKey])
|
321
|
+
}
|
322
|
+
}
|
323
|
+
for (var i = 0, end = allWaypoints.length; i < end; i++) {
|
324
|
+
allWaypoints[i].destroy()
|
325
|
+
}
|
326
|
+
}
|
327
|
+
|
328
|
+
/* Public */
|
329
|
+
/* http://imakewebthings.com/waypoints/api/context-refresh */
|
330
|
+
Context.prototype.refresh = function() {
|
331
|
+
var isWindow = this.element === this.element.window
|
332
|
+
var contextOffset = this.adapter.offset()
|
333
|
+
var triggeredGroups = {}
|
334
|
+
var axes
|
335
|
+
|
336
|
+
this.handleScroll()
|
337
|
+
axes = {
|
338
|
+
horizontal: {
|
339
|
+
contextOffset: isWindow ? 0 : contextOffset.left,
|
340
|
+
contextScroll: isWindow ? 0 : this.oldScroll.x,
|
341
|
+
contextDimension: this.innerWidth(),
|
342
|
+
oldScroll: this.oldScroll.x,
|
343
|
+
forward: 'right',
|
344
|
+
backward: 'left',
|
345
|
+
offsetProp: 'left'
|
346
|
+
},
|
347
|
+
vertical: {
|
348
|
+
contextOffset: isWindow ? 0 : contextOffset.top,
|
349
|
+
contextScroll: isWindow ? 0 : this.oldScroll.y,
|
350
|
+
contextDimension: this.innerHeight(),
|
351
|
+
oldScroll: this.oldScroll.y,
|
352
|
+
forward: 'down',
|
353
|
+
backward: 'up',
|
354
|
+
offsetProp: 'top'
|
355
|
+
}
|
356
|
+
}
|
357
|
+
|
358
|
+
for (var axisKey in axes) {
|
359
|
+
var axis = axes[axisKey]
|
360
|
+
for (var waypointKey in this.waypoints[axisKey]) {
|
361
|
+
var waypoint = this.waypoints[axisKey][waypointKey]
|
362
|
+
var adjustment = waypoint.options.offset
|
363
|
+
var oldTriggerPoint = waypoint.triggerPoint
|
364
|
+
var elementOffset = 0
|
365
|
+
var freshWaypoint = oldTriggerPoint == null
|
366
|
+
var contextModifier, wasBeforeScroll, nowAfterScroll
|
367
|
+
var triggeredBackward, triggeredForward
|
368
|
+
|
369
|
+
if (waypoint.element !== waypoint.element.window) {
|
370
|
+
elementOffset = waypoint.adapter.offset()[axis.offsetProp]
|
371
|
+
}
|
372
|
+
|
373
|
+
if (typeof adjustment === 'function') {
|
374
|
+
adjustment = adjustment.apply(waypoint)
|
375
|
+
}
|
376
|
+
else if (typeof adjustment === 'string') {
|
377
|
+
adjustment = parseFloat(adjustment)
|
378
|
+
if (waypoint.options.offset.indexOf('%') > - 1) {
|
379
|
+
adjustment = Math.ceil(axis.contextDimension * adjustment / 100)
|
380
|
+
}
|
381
|
+
}
|
382
|
+
|
383
|
+
contextModifier = axis.contextScroll - axis.contextOffset
|
384
|
+
waypoint.triggerPoint = elementOffset + contextModifier - adjustment
|
385
|
+
wasBeforeScroll = oldTriggerPoint < axis.oldScroll
|
386
|
+
nowAfterScroll = waypoint.triggerPoint >= axis.oldScroll
|
387
|
+
triggeredBackward = wasBeforeScroll && nowAfterScroll
|
388
|
+
triggeredForward = !wasBeforeScroll && !nowAfterScroll
|
389
|
+
|
390
|
+
if (!freshWaypoint && triggeredBackward) {
|
391
|
+
waypoint.queueTrigger(axis.backward)
|
392
|
+
triggeredGroups[waypoint.group.id] = waypoint.group
|
393
|
+
}
|
394
|
+
else if (!freshWaypoint && triggeredForward) {
|
395
|
+
waypoint.queueTrigger(axis.forward)
|
396
|
+
triggeredGroups[waypoint.group.id] = waypoint.group
|
397
|
+
}
|
398
|
+
else if (freshWaypoint && axis.oldScroll >= waypoint.triggerPoint) {
|
399
|
+
waypoint.queueTrigger(axis.forward)
|
400
|
+
triggeredGroups[waypoint.group.id] = waypoint.group
|
401
|
+
}
|
402
|
+
}
|
403
|
+
}
|
404
|
+
|
405
|
+
for (var groupKey in triggeredGroups) {
|
406
|
+
triggeredGroups[groupKey].flushTriggers()
|
407
|
+
}
|
408
|
+
|
409
|
+
return this
|
410
|
+
}
|
411
|
+
|
412
|
+
/* Private */
|
413
|
+
Context.findOrCreateByElement = function(element) {
|
414
|
+
return Context.findByElement(element) || new Context(element)
|
415
|
+
}
|
416
|
+
|
417
|
+
/* Private */
|
418
|
+
Context.refreshAll = function() {
|
419
|
+
for (var contextId in contexts) {
|
420
|
+
contexts[contextId].refresh()
|
421
|
+
}
|
422
|
+
}
|
423
|
+
|
424
|
+
/* Public */
|
425
|
+
/* http://imakewebthings.com/waypoints/api/context-find-by-element */
|
426
|
+
Context.findByElement = function(element) {
|
427
|
+
return contexts[element.waypointContextKey]
|
428
|
+
}
|
429
|
+
|
430
|
+
window.onload = function() {
|
431
|
+
if (oldWindowLoad) {
|
432
|
+
oldWindowLoad()
|
433
|
+
}
|
434
|
+
Context.refreshAll()
|
435
|
+
}
|
436
|
+
Waypoint.Context = Context
|
437
|
+
}())
|
438
|
+
;(function() {
|
439
|
+
'use strict'
|
440
|
+
|
441
|
+
function byTriggerPoint(a, b) {
|
442
|
+
return a.triggerPoint - b.triggerPoint
|
443
|
+
}
|
444
|
+
|
445
|
+
function byReverseTriggerPoint(a, b) {
|
446
|
+
return b.triggerPoint - a.triggerPoint
|
447
|
+
}
|
448
|
+
|
449
|
+
var groups = {
|
450
|
+
vertical: {},
|
451
|
+
horizontal: {}
|
452
|
+
}
|
453
|
+
var Waypoint = window.Waypoint
|
454
|
+
|
455
|
+
/* http://imakewebthings.com/waypoints/api/group */
|
456
|
+
function Group(options) {
|
457
|
+
this.name = options.name
|
458
|
+
this.axis = options.axis
|
459
|
+
this.id = this.name + '-' + this.axis
|
460
|
+
this.waypoints = []
|
461
|
+
this.clearTriggerQueues()
|
462
|
+
groups[this.axis][this.name] = this
|
463
|
+
}
|
464
|
+
|
465
|
+
/* Private */
|
466
|
+
Group.prototype.add = function(waypoint) {
|
467
|
+
this.waypoints.push(waypoint)
|
468
|
+
}
|
469
|
+
|
470
|
+
/* Private */
|
471
|
+
Group.prototype.clearTriggerQueues = function() {
|
472
|
+
this.triggerQueues = {
|
473
|
+
up: [],
|
474
|
+
down: [],
|
475
|
+
left: [],
|
476
|
+
right: []
|
477
|
+
}
|
478
|
+
}
|
479
|
+
|
480
|
+
/* Private */
|
481
|
+
Group.prototype.flushTriggers = function() {
|
482
|
+
for (var direction in this.triggerQueues) {
|
483
|
+
var waypoints = this.triggerQueues[direction]
|
484
|
+
var reverse = direction === 'up' || direction === 'left'
|
485
|
+
waypoints.sort(reverse ? byReverseTriggerPoint : byTriggerPoint)
|
486
|
+
for (var i = 0, end = waypoints.length; i < end; i += 1) {
|
487
|
+
var waypoint = waypoints[i]
|
488
|
+
if (waypoint.options.continuous || i === waypoints.length - 1) {
|
489
|
+
waypoint.trigger([direction])
|
490
|
+
}
|
491
|
+
}
|
492
|
+
}
|
493
|
+
this.clearTriggerQueues()
|
494
|
+
}
|
495
|
+
|
496
|
+
/* Private */
|
497
|
+
Group.prototype.next = function(waypoint) {
|
498
|
+
this.waypoints.sort(byTriggerPoint)
|
499
|
+
var index = Waypoint.Adapter.inArray(waypoint, this.waypoints)
|
500
|
+
var isLast = index === this.waypoints.length - 1
|
501
|
+
return isLast ? null : this.waypoints[index + 1]
|
502
|
+
}
|
503
|
+
|
504
|
+
/* Private */
|
505
|
+
Group.prototype.previous = function(waypoint) {
|
506
|
+
this.waypoints.sort(byTriggerPoint)
|
507
|
+
var index = Waypoint.Adapter.inArray(waypoint, this.waypoints)
|
508
|
+
return index ? this.waypoints[index - 1] : null
|
509
|
+
}
|
510
|
+
|
511
|
+
/* Private */
|
512
|
+
Group.prototype.queueTrigger = function(waypoint, direction) {
|
513
|
+
this.triggerQueues[direction].push(waypoint)
|
514
|
+
}
|
515
|
+
|
516
|
+
/* Private */
|
517
|
+
Group.prototype.remove = function(waypoint) {
|
518
|
+
var index = Waypoint.Adapter.inArray(waypoint, this.waypoints)
|
519
|
+
if (index > -1) {
|
520
|
+
this.waypoints.splice(index, 1)
|
521
|
+
}
|
522
|
+
}
|
523
|
+
|
524
|
+
/* Public */
|
525
|
+
/* http://imakewebthings.com/waypoints/api/first */
|
526
|
+
Group.prototype.first = function() {
|
527
|
+
return this.waypoints[0]
|
528
|
+
}
|
529
|
+
|
530
|
+
/* Public */
|
531
|
+
/* http://imakewebthings.com/waypoints/api/last */
|
532
|
+
Group.prototype.last = function() {
|
533
|
+
return this.waypoints[this.waypoints.length - 1]
|
534
|
+
}
|
535
|
+
|
536
|
+
/* Private */
|
537
|
+
Group.findOrCreate = function(options) {
|
538
|
+
return groups[options.axis][options.name] || new Group(options)
|
539
|
+
}
|
540
|
+
|
541
|
+
Waypoint.Group = Group
|
542
|
+
}())
|
543
|
+
;(function() {
|
544
|
+
'use strict'
|
545
|
+
|
546
|
+
var $ = window.jQuery
|
547
|
+
var Waypoint = window.Waypoint
|
548
|
+
|
549
|
+
function JQueryAdapter(element) {
|
550
|
+
this.$element = $(element)
|
551
|
+
}
|
552
|
+
|
553
|
+
$.each([
|
554
|
+
'innerHeight',
|
555
|
+
'innerWidth',
|
556
|
+
'off',
|
557
|
+
'offset',
|
558
|
+
'on',
|
559
|
+
'outerHeight',
|
560
|
+
'outerWidth',
|
561
|
+
'scrollLeft',
|
562
|
+
'scrollTop'
|
563
|
+
], function(i, method) {
|
564
|
+
JQueryAdapter.prototype[method] = function() {
|
565
|
+
var args = Array.prototype.slice.call(arguments)
|
566
|
+
return this.$element[method].apply(this.$element, args)
|
567
|
+
}
|
568
|
+
})
|
569
|
+
|
570
|
+
$.each([
|
571
|
+
'extend',
|
572
|
+
'inArray',
|
573
|
+
'isEmptyObject'
|
574
|
+
], function(i, method) {
|
575
|
+
JQueryAdapter[method] = $[method]
|
576
|
+
})
|
577
|
+
|
578
|
+
Waypoint.adapters.push({
|
579
|
+
name: 'jquery',
|
580
|
+
Adapter: JQueryAdapter
|
581
|
+
})
|
582
|
+
Waypoint.Adapter = JQueryAdapter
|
583
|
+
}())
|
584
|
+
;(function() {
|
585
|
+
'use strict'
|
586
|
+
|
587
|
+
var Waypoint = window.Waypoint
|
588
|
+
|
589
|
+
function createExtension(framework) {
|
590
|
+
return function() {
|
591
|
+
var waypoints = []
|
592
|
+
var overrides = arguments[0]
|
593
|
+
|
594
|
+
if (framework.isFunction(arguments[0])) {
|
595
|
+
overrides = framework.extend({}, arguments[1])
|
596
|
+
overrides.handler = arguments[0]
|
597
|
+
}
|
598
|
+
|
599
|
+
this.each(function() {
|
600
|
+
var options = framework.extend({}, overrides, {
|
601
|
+
element: this
|
602
|
+
})
|
603
|
+
if (typeof options.context === 'string') {
|
604
|
+
options.context = framework(this).closest(options.context)[0]
|
605
|
+
}
|
606
|
+
waypoints.push(new Waypoint(options))
|
607
|
+
})
|
608
|
+
|
609
|
+
return waypoints
|
610
|
+
}
|
611
|
+
}
|
612
|
+
|
613
|
+
if (window.jQuery) {
|
614
|
+
window.jQuery.fn.waypoint = createExtension(window.jQuery)
|
615
|
+
}
|
616
|
+
if (window.Zepto) {
|
617
|
+
window.Zepto.fn.waypoint = createExtension(window.Zepto)
|
618
|
+
}
|
619
|
+
}())
|
620
|
+
;
|
@@ -0,0 +1,65 @@
|
|
1
|
+
/*!
|
2
|
+
Waypoints Sticky Element Shortcut - 3.0.0
|
3
|
+
Copyright © 2011-2014 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,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'waypoints_rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "waypoints_rails"
|
8
|
+
spec.version = WaypointsRails::VERSION
|
9
|
+
spec.authors = ["Richard Tan", "Tom Broomfield"]
|
10
|
+
spec.email = ["chardos@gmail.com", "tomplbroomfield@gmail.com"]
|
11
|
+
spec.summary = %q{Simple asset pipeline for waypoints.}
|
12
|
+
# spec.description = %q{TODO: Write a longer description. Optional.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: waypoints_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Richard Tan
|
8
|
+
- Tom Broomfield
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-01-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.7'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.7'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '10.0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '10.0'
|
42
|
+
description:
|
43
|
+
email:
|
44
|
+
- chardos@gmail.com
|
45
|
+
- tomplbroomfield@gmail.com
|
46
|
+
executables: []
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- ".gitignore"
|
51
|
+
- Gemfile
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- lib/waypoints_rails.rb
|
56
|
+
- lib/waypoints_rails/version.rb
|
57
|
+
- vendor/assets/javascripts/infinite.js
|
58
|
+
- vendor/assets/javascripts/inview.js
|
59
|
+
- vendor/assets/javascripts/jquery.waypoints.js
|
60
|
+
- vendor/assets/javascripts/sticky.js
|
61
|
+
- waypoints_rails.gemspec
|
62
|
+
homepage: ''
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.4.5
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: Simple asset pipeline for waypoints.
|
86
|
+
test_files: []
|