forcedotcom / scrollerjs

A JavaScript library that helps you build performant UI components for the web.
http://scrollerjs.com
Apache License 2.0
636 stars 63 forks source link

resize and orientationchange events #19

Open serhiisol opened 9 years ago

serhiisol commented 9 years ago

Hi.

I've found, that scroller subscribes on resize and orientationchange events and executes resize method inside.

Android with adjustResize windowSoftInputMode triggers event resize, but sometimes its important not to resize scroller on previous page.

Just for instance, I have my own navigation system, which detaches previous view from the dom, but still keeps dom node inside and still executes and listens to some events (resize as well).

According to that my view node has 100% width and height of parents node, resize method will calculate incorrect scroller size and position or something else.

I can't prevent execution of resize method except commenting it inside library, but it is not a good practice.

If I'll comment it, everything works fine.

For real resize event, we can add additional listener manually, just for instance with jquery:

$(window).on('resize', function () {
    scroller.resize();
});
$(window).on('orientationchange', function () {
    scroller.resize();
});

Please, add feature for disabling resize after resize and orientationchange events, like option:

var scroller = new Scroller(el, {
    listenResize: false
});

Or don't listen to resize or orientationchange events.

Thanks.

PS: I can create PR, if you'll agree with it.