jonkwheeler / ScrollScene

ScrollScene is an extra layer on top of ScrollMagic as well as using IntersectionObserver to achieve similar effects.
https://scrollscene.jonkwheeler.now.sh/
MIT License
136 stars 9 forks source link

Toggle not working #36

Closed jamespurnama1 closed 4 years ago

jamespurnama1 commented 4 years ago

I'm having issues regarding the toggle option

const reveal = document.querySelectorAll(".reveal");

const imagesScene = new ScrollScene({
  triggerElement: "#trigger",
  duration: "95%",
  gsap: {
    timeline: tween
  },
  toggle: {
    element: reveal,
    className: 'visible'
  }
})

and console is returning this

I'm just using vanilla.js ScrollMagic 2.0.7 and ScrollScene 0.0.18 (import { ScrollScene } from 'scrollscene') Sorry if the solution is obvious as I am a beginner but I did read the README.md thoroughly

jonkwheeler commented 4 years ago

As mentioned in the README you cannot supply the triggerElement a type of string. https://github.com/jonkwheeler/ScrollScene#options

Give it a DOM node.

const domNode = document.querySelector("#trigger");

Also, you cannot toggle multiple elements with the way you have it. You need to supply a single element.

const reveal = document.querySelectorAll(".reveal")[0];

or 

const reveal = document.querySelector(".reveal");

Try following the examples given and let me know if it works. https://github.com/jonkwheeler/ScrollScene#toggle-a-classname

jamespurnama1 commented 4 years ago

Awesome it works now thank you!

is the Invalid value for option "offset": NaN normal? It didn't appear in older versions of ScrollScene.

jonkwheeler commented 4 years ago

Unsure on that bit! I'll have to take a look.

jonkwheeler commented 4 years ago

Alright, pull 0.0.20 and it should be gone.