Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome Drag & Drop triggering :hover pseudo-class on surrounding elements

I'm running into very frustrating and unexpected drag and drop behavior in Chrome.

Problem:

The :hover pseudo-class is triggered and stuck on surrounding elements, particularly ones where the DragElement's ghost is overlapping it.

Steps to reproduce the issue:

  • Example: http://plnkr.co/edit/PayXodHUtxqUZsM3T2ye then preview in Separate Window
  • Click and drag any of the number boxes.
  • Drop it any of the other boxes with its ghost slightly overlapping surrounding elements.

This happens in Chrome 35, 36, and 38-beta. I also noticed this isn't happening in Plunker's Run frame with the editor, but is happening in the full windowed view (linked above). It also happens in my node-webkit app (where I discovered this problem).

What I've tried so far:

  • Using -webkit-user-drag: element; on .box
  • Adding draggable="true" attribute on each .box element to see if there's a difference.
  • event.stopPropagation on various elements, including window

Why would it be triggering :hover on the surrounding elements? It makes absolutely no sense. I'm about to rip my hair out! :/

Thanks in advance for anyone who is willing to help me solve this.

like image 645
Andy Merskin Avatar asked Aug 29 '14 17:08

Andy Merskin


People also ask

How do I drag in Chrome?

It's an extremely enhanced feature for Chrome. With Super Drag, you can never be more easily open links or searches in one web page. Just hold on your left mouse button, performing a drag-n-drop, yeah, links open in the new tab.

Why can't I drag and drop into Chrome?

Fixing Drag-and-DropType "Touch" into the search bar and set the following options to "Enabled". You will have to relaunch Google Chrome for these setting changes to apply. Once you have relaunched Google Chrome, drag-and-drop gestures should now work on most compatible websites.

How do you click and drag on Chrome mobile?

To switch the behavior of a single click between left click and right click, tap the Mouse button. A double tap acts as a double click. A double tap and hold allows you to grab and then drag. A two-finger tap acts as a right click.


Video Answer


1 Answers

Have you considered jQuery UI? I know the less external resources the better, but jQuery UI detects when you are dragging, and then (as "The Reveller" said), you could add a class to body and specify

.bodyIsDragging{
   pointer-events: none
 }
like image 109
edvilme Avatar answered Sep 23 '22 00:09

edvilme