wieringen / tinyscrollbar

A lightweight cross browser javascript scrollbar.
http://baijs.com/tinyscrollbar
Other
398 stars 203 forks source link

No touch move when scrollbar is inactive #50

Closed sprat closed 9 years ago

sprat commented 9 years ago

I've spotted a bug when using your library in a responsive context: when the scrollbar is inactive (which is the case in our tablet/mobile responsive breakpoints), it still catches the touchmove events and prevents the page from scrolling. It's specially annoying when the scrollable content take all the available screen space ;)

To solve the problem, I've changed these lines :

document.ontouchmove = function(event)
{
    if(self.options.touchLock || isAtBegin() && isAtEnd())
    {
        event.preventDefault();
    }
    drag(event.touches[0]);
};

By:

document.ontouchmove = function(event)
{
    if((self.options.touchLock || isAtBegin() && isAtEnd()) && (self.contentRatio < 1))
    {
        event.preventDefault();
    }
    drag(event.touches[0]);
};

And it seems to work fine! However, I am not sure what these lines are supposed to do in the first place, so please double-check the suggested fix.

wieringen commented 9 years ago

Hey can you check the latest version to see if its fixed (on git)? I used your fix just added some more clearity.

sprat commented 9 years ago

Hello,

I've integrated the new version in our application and it works fine. Thanks for the quick update ;)

Sylvain

2015-01-14 13:08 GMT+01:00 Maarten Baijs notifications@github.com:

Hey can you check the latest version to see if its fixed?

— Reply to this email directly or view it on GitHub https://github.com/wieringen/tinyscrollbar/issues/50#issuecomment-69907355 .

Sylvain PRAT +33 06 78 71 51 21