desandro / draggabilly

:point_down: Make that shiz draggable
https://draggabilly.desandro.com
MIT License
3.86k stars 387 forks source link

Change z-index when dragging #119

Closed ASTN1 closed 8 years ago

ASTN1 commented 8 years ago

Hi,

I would like to set a CSS property (z-index: 9999) on each element that has been dragged.

I thought about using the dragEnd event, but 'pointer' isn't an object...

$draggable.on( 'dragEnd', function( event, pointer ) {
    pointer.css('z-index', '9999');
});

As far as I know there isn't a class for dragged elements...

Any idea?

desandro commented 8 years ago

Draggabilly adds is-dragging class. You can use CSS

.is-dragging {
  z-index: 2;
}
ASTN1 commented 8 years ago

Thank you for your answer, but this class disappear as soon as you drop the div, isn't?

desandro commented 8 years ago

Try this code:

$draggable.on( 'dragEnd', function( event ) {
    $( event.currentTarget ).css({ zIndex: 9999 );
});