-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(AddBaseTypePlugin): refreshing the history when add base type ele…
…ment (#532) * fix(plugin): fix the DringPlugin.ts that the cursor style grab and grabbing is not so much available * refactor(fabric-history): refactor the fabric-history and tuning the HistoryPlugin * refactor(fabric-history): refactor the fabric-history and tuning the HistoryPlugin * refactor(fabric-history): refactor the fabric-history and tuning the HistoryPlugin * refactor(fabric-history): refactor the fabric-history and tuning the HistoryPlugin * refactor(fabric-history): refactor the fabric-history and tuning the HistoryPlugin * refactor(fabric-history): refactor the fabric-history and tuning the HistoryPlugin * refactor(fabric-history): refactor the fabric-history and tuning the HistoryPlugin * refactor(fabric-history): refactor the fabric-history and tuning the HistoryPlugin * feat(plugin): adding support for the middle mouse button event to drag the workspace * fix(AddBaseTypePlugin): refreshing the history when add base type element --------- Co-authored-by: GeorgeSmith <[email protected]>
- Loading branch information
1 parent
6dca813
commit 897c53b
Showing
4 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* @Author: George | ||
* @Date: 2024-10-29 11:11:11 | ||
* @LastEditors: George | ||
* @LastEditTime: 2024-10-29 11:11:11 | ||
* @Description: 鼠标中键点击事件插件 | ||
*/ | ||
|
||
import { fabric } from 'fabric'; | ||
import type { IEditor, IPluginTempl } from '@kuaitu/core'; | ||
|
||
class MiddleMousePlugin implements IPluginTempl { | ||
static pluginName = 'MiddleMousePlugin'; | ||
workspaceEl!: HTMLElement; | ||
|
||
constructor(public canvas: fabric.Canvas, public editor: IEditor) { | ||
this.init(); | ||
} | ||
|
||
private init() { | ||
const workspaceEl = document.querySelector('#workspace') as HTMLElement; | ||
if (!workspaceEl) { | ||
throw new Error('element #workspace is missing, plz check!'); | ||
} | ||
this.workspaceEl = workspaceEl; | ||
this.initListener(); | ||
} | ||
|
||
private handleMouseUp = (e: MouseEvent) => e.button === 1 && this.canvas.fire('mouse:up', { e }); | ||
|
||
private handleMouseDown = (e: MouseEvent) => | ||
e.button === 1 && this.canvas.fire('mouse:down', { e }); | ||
|
||
/** | ||
* @desc 初始化鼠标中键监听事件 | ||
*/ | ||
private initListener() { | ||
this.workspaceEl.addEventListener('mouseup', this.handleMouseUp); | ||
this.workspaceEl.addEventListener('mousedown', this.handleMouseDown); | ||
} | ||
|
||
destroy() { | ||
this.workspaceEl.removeEventListener('mouseup', this.handleMouseUp); | ||
this.workspaceEl.removeEventListener('mousedown', this.handleMouseDown); | ||
console.log('pluginDestroy'); | ||
} | ||
} | ||
|
||
export default MiddleMousePlugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters