Mootools detect page movement

3

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

Look at a similar example , but this just does scroll . I want something like this to happen but only when we roll the page for example at 1500px from the top.

    
asked by anonymous 23.11.2014 / 18:35

1 answer

3

I've got it ..

Anyway stay here, can anyone need it.

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');
    });
});

link

    
23.11.2014 / 18:51