diff --git a/src/components/mini-map/mini-map.tsx b/src/components/mini-map/mini-map.tsx index e334d68..a4230e3 100644 --- a/src/components/mini-map/mini-map.tsx +++ b/src/components/mini-map/mini-map.tsx @@ -181,10 +181,16 @@ export const MiniMap: React.FC = ({ useEffect(() => { const move = (e: MouseEvent) => { - if (panning && isDown && instance.contentComponent) { + if ( + panning && + isDown && + instance.contentComponent && + previewRef.current && + mainRef.current + ) { const scale = computeMiniMapScale(); - const previewRect = previewRef.current?.getBoundingClientRect()!; - const mainRect = mainRef.current?.getBoundingClientRect()!; + const previewRect = previewRef.current.getBoundingClientRect(); + const mainRect = mainRef.current.getBoundingClientRect(); const relativeX = (e.clientX - mainRect.left) / scale; const relativeY = (e.clientY - mainRect.top) / scale; diff --git a/src/constants/state.constants.ts b/src/constants/state.constants.ts index 12aa9f2..f6ab759 100644 --- a/src/constants/state.constants.ts +++ b/src/constants/state.constants.ts @@ -1,4 +1,8 @@ -import { LibrarySetup, ReactZoomPanPinchState, ReactZoomPanPinchBaseClasses } from "../models/context.model"; +import { + LibrarySetup, + ReactZoomPanPinchState, + ReactZoomPanPinchBaseClasses, +} from "../models/context.model"; export const initialState: ReactZoomPanPinchState = { previousScale: 1, @@ -92,4 +96,4 @@ export const initialSetup: LibrarySetup = { export const baseClasses: ReactZoomPanPinchBaseClasses = { wrapperClass: "react-transform-wrapper", contentClass: "react-transform-component", -}; \ No newline at end of file +}; diff --git a/src/core/instance.core.ts b/src/core/instance.core.ts index e2e270f..f25717a 100644 --- a/src/core/instance.core.ts +++ b/src/core/instance.core.ts @@ -483,11 +483,6 @@ export class ZoomPanPinch { setKeyPressed = (e: KeyboardEvent): void => { this.pressedKeys[e.key] = true; - console.log( - Object.entries(this.pressedKeys) - .filter(([, pressed]) => pressed) - .map(([key]) => key), - ); }; setKeyUnPressed = (e: KeyboardEvent): void => { diff --git a/src/core/pan/velocity.logic.ts b/src/core/pan/velocity.logic.ts index db86eb8..d3ab90e 100644 --- a/src/core/pan/velocity.logic.ts +++ b/src/core/pan/velocity.logic.ts @@ -15,7 +15,7 @@ export function getSizeMultiplier(wrapperComponent: HTMLDivElement): number { const defaultMultiplier = 1; const value = wrapperComponent.offsetWidth / window.innerWidth; - if (isNaN(value)) { + if (Number.isNaN(value)) { return defaultMultiplier; } @@ -29,7 +29,7 @@ const getMinMaxVelocity = ( ) => { const defaultMultiplier = 0; const value = velocity * sensitivity; - if (isNaN(value)) { + if (Number.isNaN(value)) { return defaultMultiplier; } if (velocity < 0) { diff --git a/src/core/pinch/pinch.logic.ts b/src/core/pinch/pinch.logic.ts index c0e5df6..3b5098c 100644 --- a/src/core/pinch/pinch.logic.ts +++ b/src/core/pinch/pinch.logic.ts @@ -18,7 +18,7 @@ const getTouchCenter = (event: TouchEvent) => { let totalX = 0; let totalY = 0; // Sum up the positions of all touches - for (let i = 0; i < 2; i++) { + for (let i = 0; i < 2; i += 1) { totalX += event.touches[i].clientX; totalY += event.touches[i].clientY; } @@ -84,7 +84,7 @@ export const handlePinchZoom = ( const panX = (center.x - (pinchPreviousCenter?.x || 0)) * scaleDiff; const panY = (center.y - (pinchPreviousCenter?.y || 0)) * scaleDiff; - if (newScale === scale && panX == 0 && panY == 0) return; + if (newScale === scale && panX === 0 && panY === 0) return; contextInstance.pinchPreviousCenter = center; diff --git a/src/utils/callback.utils.ts b/src/utils/callback.utils.ts index b0b8c55..2e1b9c7 100644 --- a/src/utils/callback.utils.ts +++ b/src/utils/callback.utils.ts @@ -1,8 +1,4 @@ -import { - ReactZoomPanPinchContext, - ReactZoomPanPinchProps, - ReactZoomPanPinchRef, -} from "../models"; +import { ReactZoomPanPinchRef } from "../models"; export const handleCallback = ( context: ReactZoomPanPinchRef, diff --git a/src/utils/helpers.utils.ts b/src/utils/helpers.utils.ts index 49d35ce..4cef7b7 100644 --- a/src/utils/helpers.utils.ts +++ b/src/utils/helpers.utils.ts @@ -6,8 +6,10 @@ export const isExcludedNode = ( node: HTMLElement, excluded: string[], ): boolean => { - return excluded.some((exclude) => - node.matches(`${matchPrefix} ${exclude}, ${matchPrefix} .${exclude}, ${matchPrefix} ${exclude} *, ${matchPrefix} .${exclude} *`), + return excluded.some((exclude) => + node.matches( + `${matchPrefix} ${exclude}, ${matchPrefix} .${exclude}, ${matchPrefix} ${exclude} *, ${matchPrefix} .${exclude} *`, + ), ); };