Skip to content

Commit

Permalink
rework shape listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisShank committed Dec 3, 2024
1 parent 7a3ac92 commit 9c63d9a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/folk-shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ export class FolkShape extends HTMLElement {
// ignore interactions from slotted elements.
if (target !== this && !target.hasAttribute('part')) return;

target.addEventListener('pointermove', this);
this.addEventListener('pointermove', this);
this.addEventListener('lostpointercapture', this);
target.setPointerCapture(event.pointerId);

Expand All @@ -397,8 +397,7 @@ export class FolkShape extends HTMLElement {
return;
}
case 'pointermove': {
const target = event.target as HTMLElement;

const target = event.composedPath()[0] as HTMLElement;
if (target === null) return;

if (target === this) {
Expand Down Expand Up @@ -452,7 +451,7 @@ export class FolkShape extends HTMLElement {
const target = event.composedPath()[0] as HTMLElement;
const interaction = target.getAttribute('part') || 'move';
this.#internals.states.delete(interaction);
target.removeEventListener('pointermove', this);
this.removeEventListener('pointermove', this);
this.removeEventListener('lostpointercapture', this);
return;
}
Expand Down

0 comments on commit 9c63d9a

Please sign in to comment.