update scroll offset before updating pin state#303
update scroll offset before updating pin state#303kasparsj wants to merge 1 commit intojanpaepke:masterfrom
Conversation
|
Mh. Actually it should be called before updatePinState as it is. It would help if you could create a fiddle of what you are experiencing... |
|
No, because construct() gets called after the feature-pinning event listeners are added, therefore at the moment updateScrollOffset() is called after updatePinState(). |
|
you're right again! Maybe we should move the whole event-listener-adding out of the constructor? Or – maybe even better – make it so that nothing will be executed outside of the constructor (which technically sounds more correct). what do you think? |
|
I think the easy way - move them out of the constructor. |
|
Mh. I know what you mean. let me reflect on this a little... |
|
So I think I found a nice way. [...]
/**
* Internal constructor function of the ScrollMagic Scene
* @private
*/
var construct = function () {
for (var key in _options) { // check supplied options
if (!DEFAULT_OPTIONS.hasOwnProperty(key)) {
log(2, "WARNING: Unknown option \"" + key + "\"");
delete _options[key];
}
}
// add getters/setters for all possible options
for (var optionName in DEFAULT_OPTIONS) {
addSceneOption(optionName);
}
// validate all options
validateOption();
};
// @include('Scene/event-management.js')
// @include('Scene/core.js')
// @include('Scene/update-params.js')
// @include('Scene/getters-setters.js')
// @include('Scene/feature-pinning.js')
// @include('Scene/feature-classToggles.js')
// INIT
construct();
return Scene;
[...]And put all the event-listener attachments at the top of What do you think? |
|
great! :) |
Hi Jan, I'm working on a website where I change the scroll position if the window gets resized. I do that so that the user sees the same section even though the contents shift. Doing so I run into a bug: if the current section was pinned (fixed), it got a wrong offset.
Basically this fix makes sure that updateScrollOffset() gets called before updatePinState().