dragjs
dragjs copied to clipboard
Events with touch screen laptop
I have a laptop with a touch screen. When I user the mouse, drag events are not triggered. I think you should register both touch and mouse events.
I have a check like this:
if(isTouch()) dragTemplate(elem, cbs, 'touchstart', 'touchmove', 'touchend');
else dragTemplate(elem, cbs, 'mousedown', 'mousemove', 'mouseup');
...
// http://stackoverflow.com/questions/4817029/whats-the-best-way-to-detect-a-touch-screen-device-using-javascript
function isTouch() {
return typeof(window.ontouchstart) != 'undefined';
}
That said, it's possible my current solution is missing something crucial. Can you provide more information? Which browser are you using?
I'm using a windows 8 laptop with chrome 43. The problem is that my laptop has a touch screen : so isTouch returns true However then I use the mouse, so no touch event is triggered so it does not work.
With a device which can handle both, touch and mouse, I think you cannot but listen for both, touch and mouse events.
Excellent point! Can you try disabling the check and registering both and let me know how that goes? I don't have a way to test it.