Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preventDefault mouseUp event look like cause error on touch device #550

Open
SimDaeSoo opened this issue Sep 19, 2024 · 2 comments
Open

Comments

@SimDaeSoo
Copy link

In the mouse up function call preventDefault as follows.
The mouse up function seems to be throwing an error in preventDefault because the passive value is registered as true.
If you need a sample repository, I'll try to create one.
If you have a different way of handling it, I'd really appreciate your help.

Sample Video

error_example_view.mp4

MouseDragHandler.prototype._mouseUp = function(event) {
let clientX;
if (event.type === 'touchend') {
clientX = Math.floor(event.changedTouches[0].clientX);
if (event.cancelable) {
event.preventDefault();
}
}
else {
clientX = Math.floor(event.clientX);
}
if (this._handlers.onMouseUp) {
const mousePosX = this._getMousePosX(clientX);
this._handlers.onMouseUp(mousePosX);
}
window.removeEventListener('mousemove', this._mouseMove, { capture: false });
window.removeEventListener('touchmove', this._mouseMove, { capture: false });
window.removeEventListener('mouseup', this._mouseUp, { capture: false });
window.removeEventListener('touchend', this._mouseUp, { capture: false });
window.removeEventListener('blur', this._mouseUp, { capture: false });
this._dragging = false;
};

MouseDragHandler.prototype._mouseUp = function(event) {
  let clientX;

  if (event.type === 'touchend') {
    clientX = Math.floor(event.changedTouches[0].clientX);

    if (event.cancelable) {
      // this preventDefault function throw error
      event.preventDefault();
    }
  }
  else {
    clientX = Math.floor(event.clientX);
  }
  ...
};

window.addEventListener('mouseup', this._mouseUp, { capture: false, passive: true });

@chrisn
Copy link
Member

chrisn commented Oct 3, 2024

Thanks for reporting this. I'm not sure what the right solution is yet. Note that the preventDefault() call was added in #252.

chrisn added a commit that referenced this issue Oct 5, 2024
@chrisn
Copy link
Member

chrisn commented Oct 5, 2024

3cf46b6 should fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants