Skip to content

Commit 34d9f6d

Browse files
4.0.1
1 parent 9122b72 commit 34d9f6d

15 files changed

+84
-39
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## v4.0.1
4+
5+
- Improve performance of `enableAll`. (Issue #454)
6+
- Handle edge case bug where Waypoint initialization during a specific part of iOS scroll bounce would cause an immediate trigger of it. (Issue #499)
7+
- Maintain `window` Context/resize-handler even when there are only non-window-context waypoints. (Issue #442)
8+
39
## v4.0.0
410

511
- Allow Sticky option `wrapper` to accept false, which will not create a wrapper and instead use the preexisting parent element. (Pull #416)

lib/jquery.waypoints.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
2-
Waypoints - 4.0.0
3-
Copyright © 2011-2015 Caleb Troughton
2+
Waypoints - 4.0.1
3+
Copyright © 2011-2016 Caleb Troughton
44
Licensed under the MIT license.
55
https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
66
*/
@@ -121,7 +121,11 @@ https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
121121
/* Public */
122122
/* http://imakewebthings.com/waypoints/api/enable-all */
123123
Waypoint.enableAll = function() {
124-
Waypoint.invokeAll('enable')
124+
Waypoint.Context.refreshAll()
125+
for (var waypointKey in allWaypoints) {
126+
allWaypoints[waypointKey].enabled = true
127+
}
128+
return this
125129
}
126130

127131
/* Public */
@@ -196,6 +200,10 @@ https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
196200
element.waypointContextKey = this.key
197201
contexts[element.waypointContextKey] = this
198202
keyCounter += 1
203+
if (!Waypoint.windowContext) {
204+
Waypoint.windowContext = true
205+
Waypoint.windowContext = new Context(window)
206+
}
199207

200208
this.createThrottledScrollHandler()
201209
this.createThrottledResizeHandler()
@@ -212,7 +220,8 @@ https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
212220
Context.prototype.checkEmpty = function() {
213221
var horizontalEmpty = this.Adapter.isEmptyObject(this.waypoints.horizontal)
214222
var verticalEmpty = this.Adapter.isEmptyObject(this.waypoints.vertical)
215-
if (horizontalEmpty && verticalEmpty) {
223+
var isWindow = this.element == this.element.window
224+
if (horizontalEmpty && verticalEmpty && !isWindow) {
216225
this.adapter.off('.waypoints')
217226
delete contexts[this.key]
218227
}
@@ -281,6 +290,9 @@ https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
281290

282291
for (var waypointKey in this.waypoints[axisKey]) {
283292
var waypoint = this.waypoints[axisKey][waypointKey]
293+
if (waypoint.triggerPoint === null) {
294+
continue
295+
}
284296
var wasBeforeTriggerPoint = axis.oldScroll < waypoint.triggerPoint
285297
var nowAfterTriggerPoint = axis.newScroll >= waypoint.triggerPoint
286298
var crossedForward = wasBeforeTriggerPoint && nowAfterTriggerPoint
@@ -400,7 +412,7 @@ https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
400412
}
401413

402414
contextModifier = axis.contextScroll - axis.contextOffset
403-
waypoint.triggerPoint = elementOffset + contextModifier - adjustment
415+
waypoint.triggerPoint = Math.floor(elementOffset + contextModifier - adjustment)
404416
wasBeforeScroll = oldTriggerPoint < axis.oldScroll
405417
nowAfterScroll = waypoint.triggerPoint >= axis.oldScroll
406418
triggeredBackward = wasBeforeScroll && nowAfterScroll
@@ -455,6 +467,7 @@ https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
455467
Context.refreshAll()
456468
}
457469

470+
458471
Waypoint.requestAnimationFrame = function(callback) {
459472
var requestFn = window.requestAnimationFrame ||
460473
window.mozRequestAnimationFrame ||

lib/jquery.waypoints.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/noframework.waypoints.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
2-
Waypoints - 4.0.0
3-
Copyright © 2011-2015 Caleb Troughton
2+
Waypoints - 4.0.1
3+
Copyright © 2011-2016 Caleb Troughton
44
Licensed under the MIT license.
55
https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
66
*/
@@ -121,7 +121,11 @@ https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
121121
/* Public */
122122
/* http://imakewebthings.com/waypoints/api/enable-all */
123123
Waypoint.enableAll = function() {
124-
Waypoint.invokeAll('enable')
124+
Waypoint.Context.refreshAll()
125+
for (var waypointKey in allWaypoints) {
126+
allWaypoints[waypointKey].enabled = true
127+
}
128+
return this
125129
}
126130

127131
/* Public */
@@ -196,6 +200,10 @@ https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
196200
element.waypointContextKey = this.key
197201
contexts[element.waypointContextKey] = this
198202
keyCounter += 1
203+
if (!Waypoint.windowContext) {
204+
Waypoint.windowContext = true
205+
Waypoint.windowContext = new Context(window)
206+
}
199207

200208
this.createThrottledScrollHandler()
201209
this.createThrottledResizeHandler()
@@ -212,7 +220,8 @@ https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
212220
Context.prototype.checkEmpty = function() {
213221
var horizontalEmpty = this.Adapter.isEmptyObject(this.waypoints.horizontal)
214222
var verticalEmpty = this.Adapter.isEmptyObject(this.waypoints.vertical)
215-
if (horizontalEmpty && verticalEmpty) {
223+
var isWindow = this.element == this.element.window
224+
if (horizontalEmpty && verticalEmpty && !isWindow) {
216225
this.adapter.off('.waypoints')
217226
delete contexts[this.key]
218227
}
@@ -281,6 +290,9 @@ https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
281290

282291
for (var waypointKey in this.waypoints[axisKey]) {
283292
var waypoint = this.waypoints[axisKey][waypointKey]
293+
if (waypoint.triggerPoint === null) {
294+
continue
295+
}
284296
var wasBeforeTriggerPoint = axis.oldScroll < waypoint.triggerPoint
285297
var nowAfterTriggerPoint = axis.newScroll >= waypoint.triggerPoint
286298
var crossedForward = wasBeforeTriggerPoint && nowAfterTriggerPoint
@@ -400,7 +412,7 @@ https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
400412
}
401413

402414
contextModifier = axis.contextScroll - axis.contextOffset
403-
waypoint.triggerPoint = elementOffset + contextModifier - adjustment
415+
waypoint.triggerPoint = Math.floor(elementOffset + contextModifier - adjustment)
404416
wasBeforeScroll = oldTriggerPoint < axis.oldScroll
405417
nowAfterScroll = waypoint.triggerPoint >= axis.oldScroll
406418
triggeredBackward = wasBeforeScroll && nowAfterScroll
@@ -455,6 +467,7 @@ https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
455467
Context.refreshAll()
456468
}
457469

470+
458471
Waypoint.requestAnimationFrame = function(callback) {
459472
var requestFn = window.requestAnimationFrame ||
460473
window.mozRequestAnimationFrame ||

lib/noframework.waypoints.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/shortcuts/infinite.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
2-
Waypoints Infinite Scroll Shortcut - 4.0.0
3-
Copyright © 2011-2015 Caleb Troughton
2+
Waypoints Infinite Scroll Shortcut - 4.0.1
3+
Copyright © 2011-2016 Caleb Troughton
44
Licensed under the MIT license.
55
https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
66
*/

lib/shortcuts/infinite.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/shortcuts/inview.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
2-
Waypoints Inview Shortcut - 4.0.0
3-
Copyright © 2011-2015 Caleb Troughton
2+
Waypoints Inview Shortcut - 4.0.1
3+
Copyright © 2011-2016 Caleb Troughton
44
Licensed under the MIT license.
55
https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
66
*/

lib/shortcuts/inview.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/shortcuts/sticky.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
2-
Waypoints Sticky Element Shortcut - 4.0.0
3-
Copyright © 2011-2015 Caleb Troughton
2+
Waypoints Sticky Element Shortcut - 4.0.1
3+
Copyright © 2011-2016 Caleb Troughton
44
Licensed under the MIT license.
55
https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
66
*/

0 commit comments

Comments
 (0)