JavaScript - - By Sam Deering

iScroll 4 Helper Code Snippets

I’ve been using the iScroll 4 plugin for a while now, it’s pretty nifty. I use it for getting touch friendly scrollbars happening – great plugin. If I get time I’ll code an extension API for it & code some demos if there is enough interest. But for now here is some code snippets.

//settings for snippets below
var scrollName = 'myScroll',
     scrollDuration = 1000,
    scrollAmount = 200;

Setup scroll with end scroll callback.

//setup scroll with end scroll callback
window[scrollName] = new iScroll(scrollName, {
    onScrollEnd: function() {
        console.log('onScrollEnd');
        //do something on end of scrolling

    }
});

Check scroll is at top of content.

//Check scroll is at top of content
window.scrollName.y

Sponsors