react-draggable icon indicating copy to clipboard operation
react-draggable copied to clipboard

Dragging over an iframe stops dragging when moving the mouse too fast

Open emaborsa opened this issue 2 years ago • 2 comments

I have already seen this and this post, but I think it is a dirty workaround. I defined a CustomDraggable component (see below), which can be used everywhere, the iframe can be i child and since I am working with other libraries such as @react-aria/dialog and @react-aria/overlays I have no control of the container and @simlmx solution does not work.

import Draggable from "react-draggable";
import styles from "./CustomDraggable.module.css";

export const CustomDraggable: FC = ({ children }) => {
  return (
    <Draggable cancel={"input, svg, button, table"}>
      <div className={styles.draggable}>{children}</div>
    </Draggable>
  );
};

emaborsa avatar Oct 13 '21 08:10 emaborsa

+1

jwangyangls avatar Jun 23 '22 02:06 jwangyangls

Hi, I also encountered losing the drag when the mouse goes over an iframe. I found a relatively simple CSS-only workaround for my needs, perhaps it works for others too.

/* Prevent iframes from stealing drag events */
.react-draggable-transparent-selection iframe {
  pointer-events: none;
}

This depends on the body class set by Draggable, and stops events from going into any iframe during a drag. Note that this workaround blocks multi-input actions, such as initiating a touch-scrolling action within an iframe while actively dragging any element on the page.

danopia avatar Aug 14 '22 13:08 danopia