score:3
Accepted answer
you could resolve that by attaching the mousemove
(and mouseup
)to the whole document
this way they will be fired no matter if the mouse gets out of the element you want to drag.
just remember to detach the event during componentwillunmount
to avoid leaks.
further more if you want you site to work on mobile you need to attach touch, pointer or drag events. see the code of the kendo-draggable abstraction for a reference. we are using it in our react components. bind to the element on componentdidmount
and detach on componentwillunmount
Source: stackoverflow.com
Related Query
- Not able to move div using mousemove in react
- not able to clear Interval using variable which is outside the react hook
- Not able to increment count using state in react
- Not able to change the value of an element using react
- Not able to add, update, delete rows in material table react using class based component. Previously it was working with functional component
- Not able to set the JSON object of Arrays in React js using axios.get function and display the object of Arrays in table
- Not able to set state in React Hooks using data received from Axios
- Not able to change React state using useState
- Not able to center content using the Box component in MaterialUI and React
- Not able to store data using react redux?
- Not able to scroll an element on click using useRef in React
- I am not able to display the pages/components in React using BrowserRouter
- React - get request using axios not able to setState
- Why am I not able to route my app using react router?
- Not able to show mongo collection using React
- Not able to align divs' inside a parent div in react
- Not able to move my marker using the library leaflet
- Not able to click list child element from side menu using react testing library
- Not able to add todo in a todo-list using react and redux. What am I doing wrong?
- not able to change value using handleChange() with spread operator (...) in react class component() on object
- not able to add items to cart from product page using react redux
- Not able to access detail information from Api using React Router not rendering on the page
- Visited state/class on div not anchor using React Js
- i cant redirect after getting a response using axios post request in react i tried using Redirect but not able to do it
- I am not able to retrieive data from my json file using react
- Not able to select suggestion list value using onFocus and onBlur in react input
- Not able to set state using this.setState in react
- I am trying to update the state using the React useState hook?? The Create Read and Delete part has been done but iam not able to update
- Why does not the background color get applied from props using state for a styled component div using react and typescript?
- State not updating when using React state hook within setInterval
More Query from same tag
- Axios GraphQl query throws internal server error but fetch() works
- Why React Components being stored as variables or as state is bad design practice
- How to combine dynamic and static routes in React
- Webpack-dev-server sub pages not found
- My button needs to be clicked twice to render the new component for the first click React
- react textarea doesn't show new lines
- React - setState does not update the value
- Loading Google script in React Component
- Props not transferring to Grand-Child
- A .map stacking cards instead of them being side by side
- Why Material-UI date overlaps value with placeholder and complains about controlled input?
- Cypress unable to find selector - React/CSS Modules/Cypress
- Is there a way to attach ReactJs events to dynamically inserted HTML from Ajax JSON response?
- React Smart and Dumb Components
- React Flow Chart: Connect link when drop anywhere on node
- How to get separation between elements that are nested inside an API object
- react-router-dom's Route do not work in my project
- React Native View Render
- How to render a multi-line text string in React
- How to make form inputs interdependent in ReactJS
- React smooth transition between different states in a component
- How to validate a radio button in react.js?
- google map react, from onGoogleApiLoaded apiIsLoaded doesn't called
- How do I make the slideshow buttons scroll through the images?
- React Router RouteParams in history
- Using React i18next do I have to use withTranslation?
- Dynamically include files (components) and dynamically inject those components
- CSS - You may need an appropriate loader to handle this file type
- Highlight the clicked page number
- How to defer load render blocking css in next.js?