Mootools detect page movement

Asked

Viewed 47 times

3

How do I detect when a page is rolled to a certain point, and when it reaches that point perform a certain action. That is, using Mootools, as the Event scroll, change the style of an element.

Take a similar example, but this just do scroll. i want something like this to happen but only when we scroll the page for example to 1500px from the top.

1 answer

3

I’ve already got..

Anyway stay here, someone might need.

var posts;
window.addEvent('domready', function(){
    posts = $$('.post');
})

window.addEvent('scroll', function(e){
    var altura = window.getScroll().y;
    posts.each(function (post) {
        if (post.getPosition().y > altura + 400) return;
        post.fade('in');
    });
});

http://jsfiddle.net/chicote/r0fuuzhj/

  • 1

    Good! +1 I’m always happy to see more people using Mootools.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.