From 71253cecfc166c1aafc864556a842e1a730a8583 Mon Sep 17 00:00:00 2001 From: pipipi-pikachu Date: Sat, 7 Aug 2021 15:48:27 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E8=A1=A5=E5=85=85=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E8=A3=81=E5=89=AA=E6=8E=A7=E5=88=B6=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../element/ImageElement/ImageClipHandler.vue | 100 ++++++++++++++++-- 1 file changed, 93 insertions(+), 7 deletions(-) diff --git a/src/views/components/element/ImageElement/ImageClipHandler.vue b/src/views/components/element/ImageElement/ImageClipHandler.vue index f2ffaeed..a533bd15 100644 --- a/src/views/components/element/ImageElement/ImageClipHandler.vue +++ b/src/views/components/element/ImageElement/ImageClipHandler.vue @@ -47,6 +47,20 @@ > +
+ + + +
@@ -389,7 +403,7 @@ export default defineComponent({ targetLeft = originPositopn.left + moveX targetTop = originPositopn.top } - else { + else if (type === 'b-r') { if (originPositopn.left + originPositopn.width + moveX > bottomPosition.width) { moveX = bottomPosition.width - (originPositopn.left + originPositopn.width) } @@ -407,6 +421,54 @@ export default defineComponent({ targetLeft = originPositopn.left targetTop = originPositopn.top } + else if (type === 't') { + if (originPositopn.top + moveY < 0) { + moveY = -originPositopn.top + } + if (originPositopn.height - moveY < minHeight) { + moveY = originPositopn.height - minHeight + } + targetWidth = originPositopn.width + targetHeight = originPositopn.height - moveY + targetLeft = originPositopn.left + targetTop = originPositopn.top + moveY + } + else if (type === 'b') { + if (originPositopn.top + originPositopn.height + moveY > bottomPosition.height) { + moveY = bottomPosition.height - (originPositopn.top + originPositopn.height) + } + if (originPositopn.height + moveY < minHeight) { + moveY = minHeight - originPositopn.height + } + targetWidth = originPositopn.width + targetHeight = originPositopn.height + moveY + targetLeft = originPositopn.left + targetTop = originPositopn.top + } + else if (type === 'l') { + if (originPositopn.left + moveX < 0) { + moveX = -originPositopn.left + } + if (originPositopn.width - moveX < minWidth) { + moveX = originPositopn.width - minWidth + } + targetWidth = originPositopn.width - moveX + targetHeight = originPositopn.height + targetLeft = originPositopn.left + moveX + targetTop = originPositopn.top + } + else { + if (originPositopn.left + originPositopn.width + moveX > bottomPosition.width) { + moveX = bottomPosition.width - (originPositopn.left + originPositopn.width) + } + if (originPositopn.width + moveX < minWidth) { + moveX = minWidth - originPositopn.width + } + targetHeight = originPositopn.height + targetWidth = originPositopn.width + moveX + targetLeft = originPositopn.left + targetTop = originPositopn.top + } topImgWrapperPosition.left = targetLeft topImgWrapperPosition.top = targetTop @@ -480,12 +542,6 @@ export default defineComponent({ position: absolute; width: 16px; height: 16px; - left: 0; - top: 0; - transform-origin: 0 0; - display: flex; - justify-content: center; - align-items: center; svg { overflow: visible; @@ -500,19 +556,49 @@ export default defineComponent({ left: 100%; top: 0; transform: rotate(90deg); + transform-origin: 0 0; cursor: nesw-resize; } &.b-l { left: 0; top: 100%; transform: rotate(-90deg); + transform-origin: 0 0; cursor: nesw-resize; } &.b-r { left: 100%; top: 100%; transform: rotate(180deg); + transform-origin: 0 0; cursor: nwse-resize; } + &.t { + cursor: n-resize; + left: 50%; + top: 0; + margin-left: -8px; + } + &.b { + cursor: n-resize; + left: 50%; + bottom: 0; + margin-left: -8px; + transform: rotate(180deg); + } + &.l { + cursor: w-resize; + left: 0; + top: 50%; + margin-top: -8px; + transform: rotate(-90deg); + } + &.r { + cursor: w-resize; + right: 0; + top: 50%; + margin-top: -8px; + transform: rotate(90deg); + } } \ No newline at end of file