daybrush / moveable

Moveable! Draggable! Resizable! Scalable! Rotatable! Warpable! Pinchable! Groupable! Snappable!
https://daybrush.com/moveable/
MIT License
10.08k stars 618 forks source link

EditableViewer cannot be clicked on mobile #720

Closed alexconstantin closed 2 years ago

alexconstantin commented 2 years ago

Environments

Description

Clicking the + / - buttons works on desktop, but on mobile it has no effect. This functionality was working in previous versions of Moveable.

daybrush commented 2 years ago

@alexconstantin I'll fix it soon.

daybrush commented 2 years ago

@alexconstantin

moveable's new version is released. Check it again.

alexconstantin commented 2 years ago

@daybrush Thank you! The button is now clickable again on mobile. However I found another scenario. Please check this link: https://codesandbox.io/s/gracious-wu-0ri1kz?file=/src/App.tsx

On the top of the page there is a button. Clicking it will alert the value "1". I've changed a bit the functionality for the +/ - buttons so that they will trigger a click event (using jQuery) on that button. However, nothing happens, both on desktop and mobile. Is the propagation of the click event stopped somehow? Is there a way to trigger click events in this scenario?

daybrush commented 2 years ago

@alexconstantin

In Moveable, stopPropagationd is applied to the click event.

And click event in react is SyntheticEvent. A problem may occur due to the difference in the order of react events and native events.

The following method is recommended.

const onButtonClick = () => {
      console.log(jQuery("#test"));
      requestAnimationFrame(() => {
        jQuery("#test").trigger("click");
      });
};
alexconstantin commented 2 years ago

@daybrush Thank you! It works now.