|
|
@ -99,6 +99,7 @@ const addSelect = () => { |
|
|
|
const height = newHeight |
|
|
|
const stageWidth = stage.value.width() |
|
|
|
const stageHeight = stage.value.height() |
|
|
|
console.log(width, height, stageWidth, stageHeight) |
|
|
|
|
|
|
|
// 计算边界约束 |
|
|
|
// 1. 左上角不超出画布左/上边界 |
|
|
@ -121,6 +122,8 @@ const addSelect = () => { |
|
|
|
boundBoxFunc(oldBoundBox, newBoundBox) { |
|
|
|
const stageWidth = stage.value.width() |
|
|
|
const stageHeight = stage.value.height() |
|
|
|
console.log('oldBoundBox', oldBoundBox) |
|
|
|
console.log('newBoundBox', newBoundBox) |
|
|
|
|
|
|
|
// 新边界必须满足以下条件: |
|
|
|
// 1. 左上角不超出画布左/上边界 |
|
|
@ -129,8 +132,8 @@ const addSelect = () => { |
|
|
|
if ( |
|
|
|
newBoundBox.x < 0 |
|
|
|
|| newBoundBox.y < 0 |
|
|
|
|| newBoundBox.x + newBoundBox.width > stageWidth |
|
|
|
|| newBoundBox.y + newBoundBox.height > stageHeight |
|
|
|
|| newBoundBox.x + Math.floor(newBoundBox.width) > stageWidth |
|
|
|
|| newBoundBox.y + Math.floor(newBoundBox.height) > stageHeight |
|
|
|
|| oldBoundBox.width - (newBoundBox.x - oldBoundBox.x) < 25 |
|
|
|
|| newBoundBox.width < 25 |
|
|
|
|| oldBoundBox.height - (newBoundBox.y - oldBoundBox.y) < 25 |
|
|
|