javascriptjqueryjquery-waypoints

Jquery Waypoints - one animation to multiple divs


How can I add one jquery waypoint animation to multiple divs?

If I add this code "class .animation" it works only for one div.

Any ideas?

$(".animation").waypoint(function(direction) {
        if (direction == "down") {
            TweenMax.to(".animation", .9,{y: 0, width: "790px", ease: Power4.easeOut});
            TweenMax.to(".animation", 1,{autoAlpha: 1, ease: Power4.easeOut});
        } else {
            TweenMax.to(".animation", 1,{y: 80,width: 0, autoAlpha: 0, ease: Power4.easeOut});
        }
    }, {
        offset: "60%"
    });

Solution

  • This is just a guess, but what if you try the following.

    $(".animation").each(function(){
      $(this).waypoint(function(direction){
        ..code..
      });
    });