desandro / draggabilly

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

can not apply mouse cursor changes when dragging #201

Closed backinfile closed 4 years ago

backinfile commented 5 years ago

can not apply mouse cursor changes when dragging.

code:

var dom = $('<div>')
    .css('border', '2px red solid')
    .css('width',100)
    .css('height',100)
    .css('position', 'fixed')
    .css('cursor', 'grab')
    .css('z-index',40000)
    .appendTo(document.body);

var drag = dom.draggabilly();
drag.on('dragStart', function(){dom.css('cursor', 'grabbing')});
drag.on('dragEnd', function(){dom.css('cursor', 'grab')});
desandro commented 5 years ago

The most straightforward way to add grab/grabbing cursor CSS is by using Draggabilly's built-in classes

.draggable {
  cursor: -webkit-grab;
  cursor: grab;
}
.draggable.is-pointer-down {
  cursor: -webkit-grabbing;
  cursor: grabbing;
}

See demo https://codepen.io/desandro/pen/938d281feb728de9fad9ee5e8d555d18