fix(behavior): adjust setCursor value logic

This commit is contained in:
Aaron 2024-06-05 23:19:35 +08:00
parent 38d690b218
commit 28f61af00f

View File

@ -94,6 +94,12 @@ export interface DragElementOptions extends BaseBehaviorOptions, Prefix<'shadow'
* <en/> Cursor style
*/
cursor?: {
/**
* <zh/>
*
* <en/> Default cursor style
*/
default?: Cursor;
/**
* <zh/>
*
@ -129,6 +135,7 @@ export class DragElement extends BaseBehavior<DragElementOptions> {
shadowStrokeOpacity: 0.9,
shadowLineDash: [5, 5],
cursor: {
default: 'default',
grab: 'grab',
grabbing: 'grabbing',
},
@ -307,9 +314,10 @@ export class DragElement extends BaseBehavior<DragElementOptions> {
if (this.isDragging) return;
const { type } = event;
const { canvas } = this.context;
const { cursor } = this.options;
if (type === CommonEvent.POINTER_ENTER) canvas.setCursor('grab');
else canvas.setCursor('default');
if (type === CommonEvent.POINTER_ENTER) canvas.setCursor(cursor?.grab || 'grab');
else canvas.setCursor(cursor?.default || 'default');
};
/**