homerjam / angular-scroll-magic

An angular directive for ScrollMagic, define pins and tweens in markup
http://homerjam.github.io/angular-scroll-magic/
MIT License
18 stars 6 forks source link

Multiple sm-class-toggle for sm-scene #9

Closed TravisL12 closed 1 year ago

TravisL12 commented 8 years ago

Hey there, I have been trying to setup two elements with sm-class-toggle that both reference the same sm-scene. The first of these elements will toggle correctly but the second one is being ignored. My structure is basically like this:

<div class='home' sm-scene='homeId' offset='1000'>

    <section class='description' sm-class-toggle='homeId' classes='class-triggers'>
        <h1>This class toggles correctly</h1>
    </section>

    <section class='features' sm-class-toggle='homeId' classes='class-does-not-trigger'>
        <h1>This class does not toggle</h1>
    </section>

</div>

When I remove the first (working) <section> the second <section> will start triggering. So either I am incorrectly assuming that this is a proper use case for ScrollMagic or perhaps the sm-class-toggle directive is not firing correctly for multiple elements.

homerjam commented 8 years ago

Thanks for reporting - I will try and look into this soon, it seems logical that this should work! For now a solution would be to wrap both section elements within the same sm-class-toggle...

<div class='home' sm-scene='homeId' offset='1000'>

    <span sm-class-toggle='homeId' classes='triggers-both'>

        <section class='description'>
            <h1>This class toggles correctly</h1>
        </section>

        <section class='features'>
            <h1>This class toggles correctly too ; )</h1>
        </section>

    </span>

</div>