Skip to content

Commit

Permalink
fix: 🐛 linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
prc5 committed Jun 28, 2024
1 parent 93fa8c4 commit b0bdd0f
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 21 deletions.
12 changes: 9 additions & 3 deletions src/components/mini-map/mini-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,16 @@ export const MiniMap: React.FC<MiniMapProps> = ({

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;
Expand Down
8 changes: 6 additions & 2 deletions src/constants/state.constants.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -92,4 +96,4 @@ export const initialSetup: LibrarySetup = {
export const baseClasses: ReactZoomPanPinchBaseClasses = {
wrapperClass: "react-transform-wrapper",
contentClass: "react-transform-component",
};
};
5 changes: 0 additions & 5 deletions src/core/instance.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
4 changes: 2 additions & 2 deletions src/core/pan/velocity.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/core/pinch/pinch.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;

Expand Down
6 changes: 1 addition & 5 deletions src/utils/callback.utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
ReactZoomPanPinchContext,
ReactZoomPanPinchProps,
ReactZoomPanPinchRef,
} from "../models";
import { ReactZoomPanPinchRef } from "../models";

export const handleCallback = <T>(
context: ReactZoomPanPinchRef,
Expand Down
6 changes: 4 additions & 2 deletions src/utils/helpers.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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} *`,
),
);
};

Expand Down

0 comments on commit b0bdd0f

Please sign in to comment.