electerious / basicScroll

Standalone parallax scrolling for mobile and desktop with CSS variables.
https://basicscroll.electerious.com
MIT License
3.63k stars 148 forks source link

Get instance element in callback? #8

Closed maubut closed 6 years ago

maubut commented 6 years ago

Hey,

What a cool library! I'm trying to figure out a way i could add or remove classes to my element from the callback (inside and outside)? Is there a way i could do like:

outside: (instance, percentage, props) => {
    console.log('viewport is outside from and to');
    instance.elem.classList.add('active');
}
christophemarois commented 6 years ago

@mikoelsuperbeasto you can already do it with the instance.getData() function

inside: (instance, percentage, props) => {
  const elem = instance.getData().elem
  elem.classList.add('something')
}
maubut commented 6 years ago

Cool thanks you!