Skip to content

Commit

Permalink
fix: unnecessary calc
Browse files Browse the repository at this point in the history
  • Loading branch information
Palanikannan1437 committed Sep 17, 2024
1 parent a8db124 commit 3972039
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { useRef, useState, useCallback, useLayoutEffect, useEffect } from "react";
import { NodeSelection } from "@tiptap/pm/state";
// extensions
import { CustomImageNodeViewProps } from "@/extensions/custom-image";
// helpers
import { cn } from "@/helpers/common";

const MIN_SIZE = 100;
Expand Down Expand Up @@ -75,11 +77,13 @@ export const CustomImageBlock: React.FC<CustomImageNodeViewProps> = (props) => {

const handleResize = useCallback(
(e: MouseEvent | TouchEvent) => {
if (!isResizing.current || !containerRef.current || !containerRect.current) return;

if (size) {
aspectRatioRef.current = Number(size.width.replace("px", "")) / Number(size.height.replace("px", ""));
}

if (!isResizing.current || !containerRef.current || !containerRect.current || !aspectRatioRef.current) return;
if (!aspectRatioRef.current) return;

const clientX = "touches" in e ? e.touches[0].clientX : e.clientX;

Expand Down

0 comments on commit 3972039

Please sign in to comment.