Skip to content

Commit

Permalink
fix: removeEventListener (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
tvardy authored Oct 21, 2023
1 parent ae08a91 commit 68484cf
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/actions/ScrollTo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ const scrollTo = ( // eslint-disable-line @typescript-eslint/explicit-module-bou
node.style.cursor = 'pointer'
}

node.addEventListener('click', event => handle(event, opts))
node.addEventListener('touchstart', event => handle(event, opts))
const _handler = (event) => handle(event, opts)

node.addEventListener('click', _handler)
node.addEventListener('touchstart', _handler)

return {
destroy () {
node.removeEventListener('click', event => handle(event, opts))
node.removeEventListener('touchstart', event => handle(event, opts))
node.removeEventListener('click', _handler)
node.removeEventListener('touchstart', _handler)
}
}
}
Expand Down

0 comments on commit 68484cf

Please sign in to comment.