janpaepke / ScrollMagic

The javascript library for magical scroll interactions.
http://ScrollMagic.io
Other
14.89k stars 2.17k forks source link

setPin() doesn't properly push followers when pinned on top #983

Open JingkangZhang opened 3 years ago

JingkangZhang commented 3 years ago

When triggerHook is 0 and element trigger is on top of the page, i.e., triggers overlap on top of the page, there's a chance (when the page is refreshed in Firefox or refreshed with dev panel open in Chrome) the style: position: fixed gets applied to the pinned element before followerPusher gets a chance to set its own height (aka pushing the followers) to the height of the pinned element. The solution is to set element trigger at least 1 px below the top of the viewport, where the triggerHook is at.

Screen Shot 2021-03-19 at 4 45 26 AM

Notice in picture 1 div with id #triggerTurnRed has style top: 0, causing the pinned element with id #opening-pin to have style position: fixed instead of position: relative and the pin spacer to not have a height.

Screen Shot 2021-03-19 at 4 45 57 AM

In picture 2, notice the same fields. Everything is as desired.