Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

103
Views
Glitches while dragging the element fastly

I want to make a whole div draggable but i want to cahnge its position dynamically while dragging using a specific child of that div (i.e. other area inside that div wont let you move it). I have written a code snippet but it glitches when i move my cursor more rapidly.

Here is the codesandbox link: codesandbox link

Here is the an example: https://qzqlyk.csb.app/

Thanks in advance!!!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Well, that is happening because your onMouseMove event listener is on box2 div. so event is triggered when you move cursor when it is hovering over box2. So when you rapidly move mouse, it goes outside of box for a moment and it does not trigger event.

You can put onMouseMove={dragMouseMove} on div with class "App" like this:

<div className="App" onMouseMove={dragMouseMove}>

and in style you can put this:

.App {
      font-family: sans-serif;
      text-align: center;
      width: 100vw;
      height: 100vh;
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!