Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - stopping a hover event while dragging

I'm creating a drag and drop image environment, where if you hover over an image, a small menu pops up overtop of it. if you click and drag the image, you can reorder them.

The problem I'm having is, I want the hover event to be disabled when you're dragging around. Currently if you drag an image around, it triggers all the hover menus on the other images you hover over.

$('ul.imglist li').mousedown(
  function() { 
    $(this).find('ul')
      .fadeOut(100); 
  });

// Image actions menu
$('ul.imglist li').hover(
  function() { 
    $(this).find('ul')
      .css('display', 'none')
      .fadeIn('fast')
      .css('display', 'block');
  },
  function() { 
    $(this).find('ul')
      .fadeOut(100); 
  });   

I have a bit of jQuery here, the bottom hover event is the one I want to disable while dragging, the top mousedown is what gets rid of the menu when you click on the image. I need something that will disable the hover while moving the mouse around, with the key still pressed down (dragging).

I tried a few things with no luck, does anyone have a suggestion?

like image 645
Dave Hunt Avatar asked Apr 08 '26 14:04

Dave Hunt


1 Answers

.hover-off {
  pointer-events: none;
}

...to the rescue: Paul Lewis + thecssninja.com w/ a pretty nice, 1-stop solution.

http://www.thecssninja.com/css/pointer-events-60fps

like image 72
JRodl3r Avatar answered Apr 11 '26 04:04

JRodl3r



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!