Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

on scroll, or on view of class event triggering

I have a class named "section2" and it is associated with TweenMax animations. I would like to scroll down the page and when I hit the "section2" class I want to play the animations I have. There are a lot of animations and they're divided up into sections. I've tried the jQuery scroll() but every time I hit the scroll wheel it replays the animation. I don't want that. How can I achieve the scrolled animation only once?

var level = function(){
        TweenLite.from(".section3-level", 1.5, { ease: Bounce.easeOut, x: -600});
        TweenLite.from(".section3-graph-men", 2, { ease: Power2.easeOut, y: 800});
        TweenLite.from(".section3-graph-women", 2, { ease: Power2.easeOut, y: 800});
        TweenLite.from(".section3-graph-header", 2, { ease: Circ.easeOut, x: -400});        
    }

example of a function I have with TweenMax/TweenLite.