Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recalculate styles of pin spacer when leaving the scene #443

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions dev/src/ScrollMagic/Scene/feature-pinning.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,16 @@ var updatePinState = function (forceUnpin) {
if (!_pinOptions.pushFollowers) {
newCSS[containerInfo.vertical ? "top" : "left"] = _options.duration * _progress;
} else if (_options.duration > 0) { // only concerns scenes with duration
if (_state === SCENE_STATE_AFTER && parseFloat(_util.css(_pinOptions.spacer, "padding-top")) === 0) {
change = true; // if in after state but havent updated spacer yet (jumped past pin)
} else if (_state === SCENE_STATE_BEFORE && parseFloat(_util.css(_pinOptions.spacer, "padding-bottom")) === 0) { // before
change = true; // jumped past fixed state upward direction
}
var
stateAfter = _state === SCENE_STATE_AFTER,
stateBefore = _state === SCENE_STATE_BEFORE,
paddingTop = parseFloat(_util.css(_pinOptions.spacer, "padding-top")),
paddingBottom = parseFloat(_util.css(_pinOptions.spacer, "padding-bottom"));

// if jumped past start/end of the scene

change = (stateAfter && paddingTop === 0 || paddingBottom !== 0) ||
(stateBefore && paddingBottom === 0 || paddingTop !== 0);
}
// set new values
_util.css(pinTarget, newCSS);
Expand Down