Skip to content

Commit 9adc20e

Browse files
Fixes imakewebthings#16: Give new waypoints temporary null offsets before refresh calculation to prevent incorrect triggers on midpage waypoint creation
1 parent 0672dc5 commit 9adc20e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

waypoints.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ Support:
298298
if (ndx < 0) {
299299
context.waypoints.push({
300300
'element': $this,
301-
'offset': $this.offset().top,
301+
'offset': null,
302302
'options': opts
303303
});
304304
}
@@ -400,10 +400,10 @@ Support:
400400
An element offset change across the current scroll point triggers
401401
the event, just as if we scrolled past it.
402402
*/
403-
if (c.oldScroll > oldOffset && c.oldScroll <= o.offset) {
403+
if (oldOffset !== null && c.oldScroll > oldOffset && c.oldScroll <= o.offset) {
404404
triggerWaypoint(o, ['up']);
405405
}
406-
else if (c.oldScroll < oldOffset && c.oldScroll >= o.offset) {
406+
else if (oldOffset !== null && c.oldScroll < oldOffset && c.oldScroll >= o.offset) {
407407
triggerWaypoint(o, ['down']);
408408
}
409409
});

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.

0 commit comments

Comments
 (0)