Skip to content
This repository was archived by the owner on Aug 5, 2025. It is now read-only.

Clear timeout on destroy #166

Merged
merged 2 commits into from
Dec 22, 2022
Merged
Changes from 1 commit
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
Next Next commit
Update longpress.js
If the component gets destroyed before the timeout is cleared, you'll be invoking a method on a node that should not exist anymore
  • Loading branch information
DiegoBM authored Dec 21, 2022
commit cb1d3a84e577ecd746344c923c804fec161f6b15
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function longpress(node, duration) {

return {
destroy() {
clearTimeout(timer);
node.removeEventListener('mousedown', handleMousedown);
node.removeEventListener('mouseup', handleMouseup);
}
Expand Down