janpaepke / ScrollMagic

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

ScrollDirection Leave === Reverse Doesn't fire anything. #1018

Open aaronstezycki opened 1 year ago

aaronstezycki commented 1 year ago

I'm creating a custom sticky component, whereby I need to add, remove classes based on position (pretty simple).

I'm just testing the following, and .on("leave") used with scrollDirection === "REVERSE" does not fire anything.

var pin = new ScrollMagic.Scene({
  triggerElement: element,
  duration: element.offsetHeight
})
  on("leave", (e) => {
    if (e.scrollDirection === "FORWARD") {
      console.log('Leave: Forward'); // Works
    }
    if (e.scrollDirection === "REVERSE") {
       console.log('Leave: Backwards'); // Does not work where you expect it too.
    }
  })

The console log tends to fire on "start" "reverse" (at the top heading up), rather than "leave" "reverse" (at the bottom heading up) where you expect it too.

I understand version 3 is here, but documentation needs updating and I don't have the time to go through this without clear help.

I do think others have hit this problem too with v2. #1004

shuklabhisekh commented 8 months ago

Hey, please assign this issue to me. I would like to work on this. @aaronstezycki could you please add a dummy code of the functionality on any online editor which is not working as it will help me to understand the issue in better way and add the link here.