From ec6f5b74a0d791b50ee26174a793d542404f2fae Mon Sep 17 00:00:00 2001 From: Jan Paepke Date: Tue, 7 Oct 2014 18:23:41 +0200 Subject: [PATCH] bugfix: scroll momentum increase over fixed elements For more info see https://github.com/janpaepke/ScrollMagic/issues/164 --- CONTRIBUTING.md | 4 ++-- dev/src/class.ScrollMagic.js | 2 +- dev/src/class.ScrollScene.js | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 168f4f5c..cc9f9ea1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -122,13 +122,13 @@ $ node dev/build ``` ## Test ScrollMagic -ScrollMagic comes with a test suite that makes sure that everything works as expected after changing the source code. +ScrollMagic comes with a test suite that makes sure that everything works as expected after changing the source code. **NOTE**: The main scene methods have not been fully specced out yet, but will be added in the future. To start the test suite call: ```Shell $ npm test ``` -It will stay active an automatically restart the test cycle whenever you change something. +It will stay active an automatically restart the test cycle whenever you change something. *Tip:* In case you don't know – to quit the process use ctrl+c. To run only a single test cycle and exit after use this: diff --git a/dev/src/class.ScrollMagic.js b/dev/src/class.ScrollMagic.js index 8916115b..a02bec7c 100644 --- a/dev/src/class.ScrollMagic.js +++ b/dev/src/class.ScrollMagic.js @@ -20,7 +20,7 @@ ** `1` => errors ** `2` => errors, warnings ** `3` => errors, warnings, debuginfo - * @param {boolean} [options._refreshInterval=100] - Some changes don't call events by default, like changing the container size or moving a scene trigger element. + * @param {boolean} [options.refreshInterval=100] - Some changes don't call events by default, like changing the container size or moving a scene trigger element. This interval polls these parameters to fire the necessary events. If you don't use custom containers, trigger elements or have static layouts, where the positions of the trigger elements don't change, you can set this to 0 disable interval checking and improve performance. * diff --git a/dev/src/class.ScrollScene.js b/dev/src/class.ScrollScene.js index 1a25a26e..a8858b91 100644 --- a/dev/src/class.ScrollScene.js +++ b/dev/src/class.ScrollScene.js @@ -562,12 +562,13 @@ }; /** - * Is called, when the mousewhel is used while over a pinned element. - * If the scene is in fixed state scroll events used to be ignored. This forwards the event to the scroll container. + * Is called, when the mousewhel is used while over a pinned element inside a div container. + * If the scene is in fixed state scroll events would be counted towards the body. This forwards the event to the scroll container. * @private */ var onMousewheelOverPin = function (e) { - if (_parent && _pin && _state === "DURING") { // in pin state + if (_parent && _pin && _state === "DURING" && !_parent.info("isDocument")) { // in pin state + e.preventDefault(); _parent.scrollTo(_parent.info("scrollPos") - (e.originalEvent.wheelDelta/3 || -e.originalEvent.detail*30)); } };