ScrollLoader 1.0

Fires an event when the user reaches a certain boundary.

This Plugin is part of MooTools PowerTools!.



Details

Author
Christoph Pojer
Current version
1.0
GitHub
cpojer/scroll-loader
Downloads
2873
Category
Request
Tags
Report
GitHub Issues

Releases


Dependencies

  • _self_/_current_:
    • Core/Events
    • Core/Options
    • Core/Element.Event
    • Core/Element.Dimensions
    • Class-Extras/Class.Binds

How to use

See Demos/index.html

You can create an instance of ScrollLoader via the following code

new ScrollLoader({
    onScroll: function(){
        // User has reached a certain boundary
        // Let's make a Request for new content

        this.detach(); // While waiting, we detach the listener so the event does not fire accidentally

        var scroll = this; // Save a reference
        new Request(url, {
            onSuccess: function(text){
                new Element('div', {text: text}).inject(myElement); // Add the new content

                scroll.attach(); // Attach the event again so the event fires when you hit the bottom again
            }
        }).get();
    }
});

Build

Build via Packager, requires MooTools Core and MooTools Class-Extras to be registered to Packager already

packager register /path/to/scroll-loader
packager build ScrollLoader/* > scroll-loader.js

To build this plugin without external dependencies use

packager build ScrollLoader/* +use-only ScrollLoader > scroll-loader.js

Configurable Options Events

Options * area: (number, defaults to 50) The boundary from the bottom/right where the event is fired in * mode: (string, defaults to vertical) Either vertical or horizontal for bottom or right * container: (element, defaults to null) The used element or the window

Events * scroll - fires when the user reaches a certain boundary specified by the 'area' option


Discuss

A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.

Found a bug in this plugin? Please report it this repository's Github Issues.

blog comments powered by Disqus