Skip to content

Commit 6207df2

Browse files
Run fresh waypoint triggers on next animation frame, fixes imakewebthings#384
1 parent f8f4865 commit 6207df2

File tree

10 files changed

+35
-18
lines changed

10 files changed

+35
-18
lines changed

CHANGELOG.md

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

3+
## v4.0.0
4+
5+
- Allow Sticky option `wrapper` to accept false, which will not create a wrapper and instead use the preexisting parent element. (Pull #416)
6+
37
## v3.1.1
48

59
- Fix bad `isWindow` checks causing errors in IE8-. (Issue #372)

lib/jquery.waypoints.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,11 @@ https://github.com/imakewebthings/waypoints/blog/master/licenses.txt
421421
}
422422
}
423423

424-
for (var groupKey in triggeredGroups) {
425-
triggeredGroups[groupKey].flushTriggers()
426-
}
424+
Waypoint.requestAnimationFrame(function() {
425+
for (var groupKey in triggeredGroups) {
426+
triggeredGroups[groupKey].flushTriggers()
427+
}
428+
})
427429

428430
return this
429431
}

lib/jquery.waypoints.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/noframework.waypoints.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,11 @@ https://github.com/imakewebthings/waypoints/blog/master/licenses.txt
421421
}
422422
}
423423

424-
for (var groupKey in triggeredGroups) {
425-
triggeredGroups[groupKey].flushTriggers()
426-
}
424+
Waypoint.requestAnimationFrame(function() {
425+
for (var groupKey in triggeredGroups) {
426+
triggeredGroups[groupKey].flushTriggers()
427+
}
428+
})
427429

428430
return this
429431
}

lib/noframework.waypoints.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/shortcuts/sticky.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ https://github.com/imakewebthings/waypoints/blog/master/licenses.txt
4141

4242
/* Private */
4343
Sticky.prototype.createWrapper = function() {
44-
this.$element.wrap(this.options.wrapper)
44+
if (this.options.wrapper) {
45+
this.$element.wrap(this.options.wrapper)
46+
}
4547
this.$wrapper = this.$element.parent()
4648
this.wrapper = this.$wrapper[0]
4749
}
@@ -50,7 +52,10 @@ https://github.com/imakewebthings/waypoints/blog/master/licenses.txt
5052
Sticky.prototype.destroy = function() {
5153
if (this.$element.parent()[0] === this.wrapper) {
5254
this.waypoint.destroy()
53-
this.$element.removeClass(this.options.stuckClass).unwrap()
55+
this.$element.removeClass(this.options.stuckClass)
56+
if (this.options.wrapper) {
57+
this.$element.unwrap()
58+
}
5459
}
5560
}
5661

lib/shortcuts/sticky.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/zepto.waypoints.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,11 @@ https://github.com/imakewebthings/waypoints/blog/master/licenses.txt
421421
}
422422
}
423423

424-
for (var groupKey in triggeredGroups) {
425-
triggeredGroups[groupKey].flushTriggers()
426-
}
424+
Waypoint.requestAnimationFrame(function() {
425+
for (var groupKey in triggeredGroups) {
426+
triggeredGroups[groupKey].flushTriggers()
427+
}
428+
})
427429

428430
return this
429431
}

lib/zepto.waypoints.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/context.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,11 @@
255255
}
256256
}
257257

258-
for (var groupKey in triggeredGroups) {
259-
triggeredGroups[groupKey].flushTriggers()
260-
}
258+
Waypoint.requestAnimationFrame(function() {
259+
for (var groupKey in triggeredGroups) {
260+
triggeredGroups[groupKey].flushTriggers()
261+
}
262+
})
261263

262264
return this
263265
}

0 commit comments

Comments
 (0)