Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/core/pan/panning.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export function handlePanning(
const paddingValueX = getPaddingValue(contextInstance, sizeX);
const paddingValueY = getPaddingValue(contextInstance, sizeY);

if(clientCoords?.x != clientX && clientCoords?.y != clientY) handleCalculateVelocity(contextInstance, { x, y });
if (clientCoords?.x != clientX && clientCoords?.y != clientY)
handleCalculateVelocity(contextInstance, { x, y });
handleNewPosition(contextInstance, x, y, paddingValueX, paddingValueY);
}

Expand Down
15 changes: 12 additions & 3 deletions src/core/pan/panning.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,18 @@ export const isPanningStartAllowed = (

const target = event.target as HTMLElement;
const targetIsShadowDom = "shadowRoot" in target && "composedPath" in event;

// Helper function to check if an object is an Element (cross-window compatible)
// Using numeric constant 1 (ELEMENT_NODE) instead of Node.ELEMENT_NODE for cross-window compatibility
const isElement = (el: unknown): el is Element => {
return (
el != null && typeof el === "object" && (el as Element).nodeType === 1
);
};

const isWrapperChild = targetIsShadowDom
? event.composedPath().some((el) => {
if (!(el instanceof Element)) {
if (!isElement(el)) {
return false;
}

Expand Down Expand Up @@ -64,7 +73,7 @@ export const handlePanningSetup = (
const y = event.clientY;

contextInstance.startCoords = { x: x - positionX, y: y - positionY };
contextInstance.clientCoords = {x: x, y: y};
contextInstance.clientCoords = { x, y };
};

export const handleTouchPanningSetup = (
Expand All @@ -82,7 +91,7 @@ export const handleTouchPanningSetup = (
const x = touches[0].clientX;
const y = touches[0].clientY;
contextInstance.startCoords = { x: x - positionX, y: y - positionY };
contextInstance.clientCoords = {x: x, y: y};
contextInstance.clientCoords = { x, y };
}
};
export function handlePanToBounds(
Expand Down