RWAP / jquery-ui-touch-punch

A duck punch for adding touch events to jQuery UI
http://touchpunch.furf.com/
102 stars 29 forks source link

JS error with draggable on windows 10 #12

Open ankoin opened 4 years ago

ankoin commented 4 years ago

Hello ! Its a very good extension for UI !

Report a bug : PC : Acer Aspire Z3-610 Windows 10 Bug on Chrome (Version 78.0.3904.108) and Firefox (71.0 (64 bits)) With Internet Explorer -> no problem Jquery : jquery-1.11.0 Jquery UI : jquery-ui-1.12.1 Jquery-ui-touch-punch : jquery-ui-touch-punch-master-1.0.5 Function UI : draggable (with tactile)

If I drag element with touchscreen, we have a JS error : TypeError: this._startPos is undefined jquery.ui.touch-punch.js:179:12

I have tested a modification with success (but i don't know if is the best solution) :

Replace :

if ((Math.abs(endPos.x - this._startPos.x) < 10) && (Math.abs(endPos.y - this._startPos.y) < 10)) {

  // If the touch interaction did not move, it should trigger a click
  if (!this._touchMoved || event.originalEvent.changedTouches[0].touchType === 'stylus') {
      // Simulate the click event
      simulateMouseEvent(event, 'click');
  }
}

by :

if (typeof this._startPos !== "undefined") {
    if ((Math.abs(endPos.x - this._startPos.x) < 10) && (Math.abs(endPos.y - this._startPos.y) < 10)) {

        // If the touch interaction did not move, it should trigger a click
        if (!this._touchMoved || event.originalEvent.changedTouches[0].touchType === 'stylus') {
            // Simulate the click event
            simulateMouseEvent(event, 'click');
        }
    }
}

Thank you !

RWAP commented 4 years ago

That is peculiar - it looks as though the touchstart was not fired. Not having a touch screen device (of any description!) can you put a break on line 109 and step through the code to see if Windows 10 is simply not firing the touchStart function (before the touchEnd), or whether something else is preventing it from reaching line 117 ?

Otherwise, your change would be fine - this is to only try and ensure that you can click on draggable elements, even if you wiggle your finger slightly

ankoin commented 4 years ago

Hello, Thank you. The problem occurs only when touching the screen and only when the draggable is released. (just before this error, the draggable works well.

RWAP commented 4 years ago

Please try the latest version of the code now.

RWAP commented 3 years ago

Did you ever manage to resolve this issue?