Scrollmagic: cant add more than one class to setClassToggle

Created on 18 Feb 2016  路  9Comments  路  Source: janpaepke/ScrollMagic

I tried adding multiple classes and it doesnt work this an error.

The token provided ('flipInX flipOutX') contains HTML space characters, which are not valid in tokens.
on:
.setClassToggle('.phone', 'flipInX flipOutX')

Most helpful comment

Example of how to trigger multiple id's at the same time

new ScrollMagic.Scene({ triggerElement: '#intro', triggerHook: 'onLeave' })
.on('enter leave', function () {
$('#nav-bar').toggleClass('background-black');
$('#threeAnim').toggleClass('display-none');
})
.addTo(controller);

All 9 comments

+1

If you are using GSAP you can use the .set() method and add multiple classes that way.

Here is a demo on CodePen.

+1
The comments in Scrollmagic.js are wrong.

  • @param {string} classes - One or more Classnames (separated by space) that should be added to the element during the scene.

This doesn't work.

Have you tried the .set method using GSAP? You only need the TweenLite to use the .set method.

Same here.

So this bug is a dealbreaker for me. Does anyone recommend an alternative library?

This behavior surprised me.

While it's not a deal breaker.

I would expect multiple uses of setClassToggle() to append behaviors to a controller.

@estevancarlos FYI, if you're using jQuery with ScrollMagic, you have a bit more flexibility since you can do multiple selectors:

https://api.jquery.com/multiple-selector/

In order words:

   new $.ScrollMagic.Scene(options)
      .duration(100)
      .setClassToggle(
        "a[href='moo'] ~ ul,a[href='moo']",
        "is-active"
      );

Example of how to trigger multiple id's at the same time

new ScrollMagic.Scene({ triggerElement: '#intro', triggerHook: 'onLeave' })
.on('enter leave', function () {
$('#nav-bar').toggleClass('background-black');
$('#threeAnim').toggleClass('display-none');
})
.addTo(controller);

Was this page helpful?
0 / 5 - 0 ratings