wieringen / tinyscrollbar

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

Scrollbar drag & drop is broken on desktop browsers #59

Open rjgotten opened 9 years ago

rjgotten commented 9 years ago

This is not how you detect and handle touch capability:

var hasTouchEvents = ("ontouchstart" in document.documentElement)

/* ... */ 

if(hasTouchEvents) {
    $viewport.ontouchstart = function(event) { /* ... */ };
} else {
    $thumb.onmousedown = function(event) { /* ... */ };
    $track.onmousedown = function(event) { /* ... */ };
};

The hasTouchEvents boolean value will be true on all desktop browsers that implement the touch event API, like Firefox and Chrome, and have, have-had or may at some time have touch-capable devices hooked up that make the OS report touch support. Those browsers are not necessarily using touch input at the moment at all.

Disjoint branching of event bindings for mouse/touch based on this boolean means anything based on mouseup/mousedown such as the drag & drop behavior, can randomly be completely broken on desktops.

You should rewrite this to use joint mouse/touch interaction support instead.

goranovs commented 9 years ago

For me this issue exists only under Firefox (tested with 38.0.1 and 38.0.5). I can scroll with mousewheel but its very slow, like 10 times slower than in Chrome and its impossible to drag or click the scroll "handler".

Chrome (43.0.2357.81 m), Opera (29.0) and IE 11 ( 10 and 9 with "devtools" ) are just fine. I'm using nojquery v2.4.2 - 2015-04-03. OS Windows 7 without touchscreen.

wieringen commented 9 years ago

Yes you are right this needs some work.

programmin1 commented 8 years ago

Oddly enough I always see this can't-drag-the-scrollbar bug in Ubuntu-14's Firefox (all versions), no other browsers.

Apparently this is because "ontouchstart" in document.documentElement is true although document.documentElement.ontouchstart is null.

Can this be easily fixed?

patstuart commented 8 years ago

For what it's worth, Chrome browser (i.e., the most popular browser) no longer works for any laptops that support touch events (i.e., the majority of modern personal computers). As far as I'm concerned this entire plugin is broken until this is fixed.

wieringen commented 8 years ago

If someone can create a pull request I will merge.

patstuart commented 8 years ago

I will have a fix in the next few days. Thanks for the help!

programmin1 commented 8 years ago

At least for me, the problem was not in the browser but in the kernel - I'm curious if you update your kernel or drivers to the latest supported, do you still have the problem? See https://bugs.launchpad.net/ubuntu/+source/firefox/+bug/1477815

rjgotten commented 8 years ago

The problem is in the fact that, like so many other libraries, tinyscrollbar incorrectly assumes the presence of an "ontouchstart" means the user is working from a device that is exclusively touch-based.

The only thing the presence of "ontouchstart" indicates is that the browser supports touch events. It says absolutely nothing about the user's current input method.

wieringen commented 8 years ago

Can you guys test the latest version (2.5.0)? It has patstuart's patch and it seems to work on my systems.