Skip to content

Commit

Permalink
fix: Mouse panning when used in shadow DOM (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlande committed Jan 31, 2024
1 parent 6167676 commit cad806b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/core/pan/panning.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@ export const isPanningStartAllowed = (
const { isInitialized, wrapperComponent } = contextInstance;

const target = event.target as HTMLElement;
const isWrapperChild = wrapperComponent?.contains(target);
const targetIsShadowDom = "shadowRoot" in target && "composedPath" in event;
const isWrapperChild = targetIsShadowDom
? event.composedPath().some((el) => {
if (!(el instanceof Element)) {
return false;
}

return wrapperComponent?.contains(el);
})
: wrapperComponent?.contains(target);

const isAllowed = isInitialized && target && isWrapperChild;

if (!isAllowed) return false;
Expand Down

0 comments on commit cad806b

Please sign in to comment.