dragjs icon indicating copy to clipboard operation
dragjs copied to clipboard

Events with touch screen laptop

Open JeanCarriere opened this issue 10 years ago • 3 comments

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.

JeanCarriere avatar Jul 20 '15 15:07 JeanCarriere

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?

bebraw avatar Jul 20 '15 15:07 bebraw

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.

JeanCarriere avatar Jul 20 '15 17:07 JeanCarriere

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.

bebraw avatar Jul 20 '15 17:07 bebraw