imakewebthings / waypoints

Waypoints is a library that makes it easy to execute a function whenever you scroll to an element.
http://imakewebthings.com/waypoints/
10.38k stars 1.34k forks source link

Waypoints and Greensock animation #187

Closed eppel2013 closed 11 years ago

eppel2013 commented 11 years ago

Hello,

I cannot get the greensock animation function to work with Waypoints

Greensock script:

window.onload = function(){
  var l = document.getElementById("logo");
  var time = 1;
  TweenLite.from(logo, time,  {left:"-632px",  scale:.3,delay:0});
}

The idea is to delay the animation until an element is in view.

Have been using this example, but am failing ...

$(function() {
  $('#x').waypoint(function(direction) {
    if (direction === "down")      
      window.location.href = 'http://www.startpage.com';
    }, {
      offset: '300',
    });
  });
});

Have been replacing the window.location.href = 'http://www.startpage.com'; with Greensock script.

If you can help, would be much appreciated. thank you

imakewebthings commented 11 years ago

There's nothing obviously wrong from the two snippets you've posted. I would need to see the page in action to debug further. The only thing I can think of is that perhaps you're combining the scripts wrong and doing this:

$(function() {
  $('#x').waypoint(function(direction) {
    if (direction === "down")      
      window.onload = function(){
        var l = document.getElementById("logo");
        var time = 1;
        TweenLite.from(logo, time,  {left:"-632px",  scale:.3,delay:0});
      }
    }, {
      offset: '300',
    });
  });
});

Where you should be leaving out the onload handler. But like I said, need to see it to know for sure.

eppel2013 commented 11 years ago

Thank you for the reply !!! This is great!