Skip to content

Commit b30dbb7

Browse files
committed
change to browser-independent method for detecting when sort has changed (fix Edge browser resetting hover every tick)
1 parent 4b09737 commit b30dbb7

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,11 @@ AFRAME.registerComponent('super-hands', {
134134
this.onDragDropEndButton()
135135
},
136136
tick: (function () {
137-
let orderChanged = false
138137
// closer objects and objects with no distance come later in list
139138
function sorter (a, b) {
140139
const aDist = a.distance == null ? -1 : a.distance
141140
const bDist = b.distance == null ? -1 : b.distance
142141
if (aDist < bDist) {
143-
orderChanged = true
144142
return 1
145143
}
146144
if (bDist < aDist) {
@@ -154,12 +152,15 @@ AFRAME.registerComponent('super-hands', {
154152
if (prevCheckTime && (time - prevCheckTime < data.interval)) { return }
155153
this.prevCheckTime = time
156154

157-
orderChanged = false
155+
let orderChanged = false
158156
this.hoverElsIntersections.sort(sorter)
159-
if (orderChanged) {
160-
for (let i = 0; i < this.hoverElsIntersections.length; i++) {
157+
for (let i = 0; i < this.hoverElsIntersections.length; i++) {
158+
if (this.hoverEls[i] !== this.hoverElsIntersections[i].object.el) {
159+
orderChanged = true
161160
this.hoverEls[i] = this.hoverElsIntersections[i].object.el
162161
}
162+
}
163+
if (orderChanged) {
163164
this.hover()
164165
}
165166
}

0 commit comments

Comments
 (0)