Skip to content

Commit

Permalink
fix(behavior): adjust setCursor value logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Aarebecca committed Jun 5, 2024
1 parent 38d690b commit 28f61af
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/g6/src/behaviors/drag-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ export interface DragElementOptions extends BaseBehaviorOptions, Prefix<'shadow'
* <en/> Cursor style
*/
cursor?: {
/**
* <zh/> 默认指针样式
*
* <en/> Default cursor style
*/
default?: Cursor;
/**
* <zh/> 可抓取指针样式
*
Expand Down Expand Up @@ -129,6 +135,7 @@ export class DragElement extends BaseBehavior<DragElementOptions> {
shadowStrokeOpacity: 0.9,
shadowLineDash: [5, 5],
cursor: {
default: 'default',
grab: 'grab',
grabbing: 'grabbing',
},
Expand Down Expand Up @@ -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');
};

/**
Expand Down

0 comments on commit 28f61af

Please sign in to comment.