From c87144f443f45a81c185556d0bc3863328eb06c5 Mon Sep 17 00:00:00 2001 From: bae-sh Date: Fri, 5 Jul 2024 00:01:21 +0900 Subject: [PATCH] fix: develop responsive height --- lib/imageResize.ts | 7 +------ package.json | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/imageResize.ts b/lib/imageResize.ts index 9d8b56d..70e8172 100644 --- a/lib/imageResize.ts +++ b/lib/imageResize.ts @@ -186,7 +186,7 @@ export const ImageResize = Image.extend({ ]; let isResizing = false; - let startX: number, startWidth: number, startHeight: number; + let startX: number, startWidth: number; $container.addEventListener('click', () => { //remove remaining dots and position controller @@ -215,21 +215,16 @@ export const ImageResize = Image.extend({ isResizing = true; startX = e.clientX; startWidth = $container.offsetWidth; - startHeight = $container.offsetHeight; const onMouseMove = (e: MouseEvent) => { if (!isResizing) return; const deltaX = index % 2 === 0 ? -(e.clientX - startX) : e.clientX - startX; - const aspectRatio = startWidth / startHeight; const newWidth = startWidth + deltaX; - const newHeight = newWidth / aspectRatio; $container.style.width = newWidth + 'px'; - $container.style.height = newHeight + 'px'; $img.style.width = newWidth + 'px'; - $img.style.height = newHeight + 'px'; }; const onMouseUp = () => { diff --git a/package.json b/package.json index 9ca2fc8..22dc2c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tiptap-extension-resize-image", - "version": "1.1.7", + "version": "1.1.8", "type": "module", "description": "A tiptap image resizing extension for React, Vue, Next, and VanillaJS. Additionally, it can align the image position.", "main": "dist/index.js",