From 507de918436bae5b96b82d993d42cff2109fb898 Mon Sep 17 00:00:00 2001 From: IchliebedichZhu <54796446@qq.com> Date: Mon, 4 Mar 2024 17:51:02 +0000 Subject: [PATCH] fix: drag animation problem --- src/common/hooks/dragHelper.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/common/hooks/dragHelper.ts b/src/common/hooks/dragHelper.ts index a6dbbab..1d5e617 100644 --- a/src/common/hooks/dragHelper.ts +++ b/src/common/hooks/dragHelper.ts @@ -113,11 +113,14 @@ export default class DragHelper { private moveFlutter(x: number, y: number, d = 0, lazy = 0) { const { width, height, finallySize } = this.initial as TInitial let scale: string | null = null - if (!d) { + if (d) { if (width > finallySize) { scale = width - d >= finallySize ? `transform: scale(${(width - d) / width});` : null - } else scale = width + d <= finallySize ? `transform: scale(${(width + d) / width})` : null + } else { + scale = width + d <= finallySize ? `transform: scale(${(width + d) / width})` : null + } } + const options = [`left: ${x}px`, `top: ${y}px`, `width: ${width}px`, `height: ${height}px`] scale && options.push(scale) options.push(`transition: all ${lazy}s`) @@ -137,9 +140,7 @@ export default class DragHelper { this.dragging = false store.commit('setDraging', false) store.commit('selectItem', {}) - if (!this.cloneEl) { - return - } + if (!done) { const { pageX, offsetX, pageY, offsetY } = this.initial as TInitial this.changeStyle([`left: ${pageX - offsetX}px`, `top: ${pageY - offsetY}px`, 'transform: scale(1)', 'transition: all 0.3s'])