-
-
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.
1 parent
929df04
commit 0a8fb97
Showing
4 changed files
with
47 additions
and
11 deletions.
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
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,26 @@ | ||
/* | ||
* @Descripttion: useCalculate | ||
* @version: | ||
* @Author: wuchenguang1998 | ||
* @Date: 2024-05-18 15:42:17 | ||
* @LastEditors: wuchenguang1998 | ||
* @LastEditTime: 2024-05-18 17:28:34 | ||
*/ | ||
|
||
export default function useCalculate() { | ||
const canvasEditor = inject('canvasEditor'); | ||
|
||
// 获取画布的DOMRect对象 | ||
const getCanvasBound = () => canvasEditor.canvas.getSelectionElement().getBoundingClientRect(); | ||
|
||
// 判断拖拽结束的坐标是否在画布外 | ||
const isOutsideCanvas = (x, y) => { | ||
const { left, right, top, bottom } = getCanvasBound(); | ||
return x < left || x > right || y < top || y > bottom; | ||
}; | ||
|
||
return { | ||
getCanvasBound, | ||
isOutsideCanvas, | ||
}; | ||
} |