Skip to content

Commit

Permalink
fix: Correct listener teardown
Browse files Browse the repository at this point in the history
Correct listeners reference in the Selections.teardown() method

jquense#2072
  • Loading branch information
cutterbl authored Dec 20, 2021
2 parents a88da3f + a202d60 commit abd4594
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/Selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class Selection {

teardown() {
this.isDetached = true
this.listeners = Object.create(null)
this._listeners = Object.create(null)
this._removeTouchMoveWindowListener && this._removeTouchMoveWindowListener()
this._removeInitialEventListener && this._removeInitialEventListener()
this._removeEndListener && this._removeEndListener()
Expand All @@ -108,7 +108,8 @@ class Selection {
this._removeKeyUpListener && this._removeKeyUpListener()
this._removeKeyDownListener && this._removeKeyDownListener()
this._removeDropFromOutsideListener && this._removeDropFromOutsideListener()
this._removeDragOverFromOutsideListener && this._removeDragOverFromOutsideListener()
this._removeDragOverFromOutsideListener &&
this._removeDragOverFromOutsideListener()
}

isSelected(node) {
Expand Down Expand Up @@ -412,8 +413,8 @@ class Selection {
let { x, y, isTouch } = this._initialEventData
return (
!isTouch &&
(Math.abs(pageX - x) <= clickTolerance &&
Math.abs(pageY - y) <= clickTolerance)
Math.abs(pageX - x) <= clickTolerance &&
Math.abs(pageY - y) <= clickTolerance
)
}
}
Expand Down Expand Up @@ -455,15 +456,17 @@ export function objectsCollide(nodeA, nodeB, tolerance = 0) {
bottom: bBottom = bTop,
} = getBoundsForNode(nodeB)

return !// 'a' bottom doesn't touch 'b' top
(
aBottom - tolerance < bTop ||
// 'a' top doesn't touch 'b' bottom
aTop + tolerance > bBottom ||
// 'a' right doesn't touch 'b' left
aRight - tolerance < bLeft ||
// 'a' left doesn't touch 'b' right
aLeft + tolerance > bRight
return !(
// 'a' bottom doesn't touch 'b' top
(
aBottom - tolerance < bTop ||
// 'a' top doesn't touch 'b' bottom
aTop + tolerance > bBottom ||
// 'a' right doesn't touch 'b' left
aRight - tolerance < bLeft ||
// 'a' left doesn't touch 'b' right
aLeft + tolerance > bRight
)
)
}

Expand Down

0 comments on commit abd4594

Please sign in to comment.