tiptap-extension-resize-image
Advanced tools
Comparing version 1.1.7 to 1.1.8
@@ -160,3 +160,3 @@ 'use strict'; | ||
let isResizing = false; | ||
let startX, startWidth, startHeight; | ||
let startX, startWidth; | ||
$container.addEventListener('click', () => { | ||
@@ -179,3 +179,2 @@ //remove remaining dots and position controller | ||
startWidth = $container.offsetWidth; | ||
startHeight = $container.offsetHeight; | ||
const onMouseMove = (e) => { | ||
@@ -185,9 +184,5 @@ if (!isResizing) | ||
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'; | ||
}; | ||
@@ -194,0 +189,0 @@ const onMouseUp = () => { |
@@ -156,3 +156,3 @@ import Image from '@tiptap/extension-image'; | ||
let isResizing = false; | ||
let startX, startWidth, startHeight; | ||
let startX, startWidth; | ||
$container.addEventListener('click', () => { | ||
@@ -175,3 +175,2 @@ //remove remaining dots and position controller | ||
startWidth = $container.offsetWidth; | ||
startHeight = $container.offsetHeight; | ||
const onMouseMove = (e) => { | ||
@@ -181,9 +180,5 @@ if (!isResizing) | ||
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'; | ||
}; | ||
@@ -190,0 +185,0 @@ const onMouseUp = () => { |
{ | ||
"name": "tiptap-extension-resize-image", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "A tiptap image resizing extension for React, Vue, Next, and VanillaJS. Additionally, it can align the image position.", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
57158
441