Skip to content
This repository has been archived by the owner on Dec 8, 2017. It is now read-only.

Commit

Permalink
Merge pull request #1 from 18F/passive-event-handlers
Browse files Browse the repository at this point in the history
make scroll and wheel events passive
  • Loading branch information
gemfarmer authored Nov 8, 2016
2 parents 3e7c488 + ed366ec commit 8f88f3b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions dist/stickyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
rebuild();
return;
}

if (win.pageYOffset != scroll.top) {
updateScrollPos();
recalcAllPos();
Expand Down Expand Up @@ -274,7 +274,7 @@
},
nodeOffset = getElementOffset(node),
parentOffset = getElementOffset(parentNode),

parent = {
node: parentNode,
css: {
Expand Down Expand Up @@ -371,8 +371,8 @@
updateScrollPos();
initAll();

win.addEventListener('scroll', onScroll);
win.addEventListener('wheel', onWheel);
win.addEventListener('scroll', onScroll, { passive: true });
win.addEventListener('wheel', onWheel, { passive: true });

//watch for width changes
win.addEventListener('resize', rebuild);
Expand All @@ -390,11 +390,11 @@
if (!initialized) return;

deinitAll();

for (var i = watchArray.length - 1; i >= 0; i--) {
watchArray[i] = getElementParams(watchArray[i].node);
}

initAll();
}

Expand All @@ -412,7 +412,7 @@

function stop() {
pause();
deinitAll();
deinitAll();
}

function kill() {
Expand Down
2 changes: 1 addition & 1 deletion dist/stickyfill.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions src/stickyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
rebuild();
return;
}

if (win.pageYOffset != scroll.top) {
updateScrollPos();
recalcAllPos();
Expand Down Expand Up @@ -267,7 +267,7 @@
},
nodeOffset = getElementOffset(node),
parentOffset = getElementOffset(parentNode),

parent = {
node: parentNode,
css: {
Expand Down Expand Up @@ -364,8 +364,8 @@
updateScrollPos();
initAll();

win.addEventListener('scroll', onScroll);
win.addEventListener('wheel', onWheel);
win.addEventListener('scroll', onScroll, { passive: true });
win.addEventListener('wheel', onWheel, { passive: true });

//watch for width changes
win.addEventListener('resize', rebuild);
Expand All @@ -383,11 +383,11 @@
if (!initialized) return;

deinitAll();

for (var i = watchArray.length - 1; i >= 0; i--) {
watchArray[i] = getElementParams(watchArray[i].node);
}

initAll();
}

Expand All @@ -405,7 +405,7 @@

function stop() {
pause();
deinitAll();
deinitAll();
}

function kill() {
Expand Down

0 comments on commit 8f88f3b

Please sign in to comment.