Stereobit / dragend

dragend JS – a touch ready, full responsive, content swipe script
http://stereobit.github.com/dragend/
MIT License
485 stars 114 forks source link

Dragend stopped working on desktop browsers (Chrome 39.0.2171.95 and Firefox) #48

Open ndkv opened 9 years ago

ndkv commented 9 years ago

Dragend doesn't work on Chrome anymore.

It seems that the isTouch = 'ontouchstart' in win check on line 100 isn't valid anymore. ontouchstart is present in win (but has a value of null) hence isTouch always evaluates to true. This breaks swiping on desktop browsers as mouse events are not handled anymore.

This was already the case with Firefox (see my brief investigation in issue #46) but is now also happening on Chrome. Last week everything worked fine on Chrome (desktop) as it didn't have an ontouchstart property in win and the check on line 100 returned false.

Oddly enough, mobile browsers also report that ontouchstart is null so I wouldn't know how to differentiate between desktop and mobile without using a full-fledged browser detection library. Any thoughts?

Stereobit commented 9 years ago

Hey @ndkv, thanks for the investigation. Since null is a falsy value - would changing it to win.ontouchstart help?

ndkv commented 9 years ago

I don't think so as ontouchstart is also null on mobile browsers. Simply checking its value will break dragend on them.

Detecting touch is a messy business (see this Stackoverflow question).

Seeing that these things apparently change overnight, I think the best strategy is to include a custom build of e.g. Modernizr to check for touch capabilities. Sadly that isn't a robust solution either.

Another option is to implement both at the same time as mentioned here and here.

0xgeert commented 9 years ago

Thinking of using this lib, but this issue makes me hesitant. Any progress?