desandro / draggabilly

:point_down: Make that shiz draggable

Home Page:https://draggabilly.desandro.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

can not apply mouse cursor changes when dragging

backinfile opened this issue · comments

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')});

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