Canvas: Set element cursor to grab (#52503)

* Only display grab cursor when editing enabled

* Apply grabbing cursor while dragging an element
This commit is contained in:
Drew Slobodnjak 2022-07-21 13:17:25 -07:00 committed by GitHub
parent 3c2ef54e04
commit bf8bb26f63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -81,7 +81,10 @@ export class ElementState implements LayerElement {
const { vertical, horizontal } = constraint ?? {};
const placement = this.options.placement ?? ({} as Placement);
const editingEnabled = this.getScene()?.isEditingEnabled;
const style: React.CSSProperties = {
cursor: editingEnabled ? 'grab' : 'auto',
position: 'absolute',
// Minimum element size is 10x10
minWidth: '10px',

View File

@ -415,6 +415,11 @@ export class Scene {
?.getSelectedTargets()
.includes(selectedTarget.parentElement.parentElement);
// Apply grabbing cursor while dragging, applyLayoutStylesToDiv() resets it to grab when done
if (this.isEditingEnabled && isTargetMoveableElement && this.selecto?.getSelectedTargets().length) {
this.selecto.getSelectedTargets()[0].style.cursor = 'grabbing';
}
if (isTargetMoveableElement || isTargetAlreadySelected) {
// Prevent drawing selection box when selected target is a moveable element or already selected
event.stop();