Skip to content

Commit 09adf84

Browse files
authored
Remove handlersToCancel on web. (#2679)
## Description While working on removing [gesture handlers limit on android](#2672) I've though that we can also remove `handlersToCancel` array on web. ## Test plan Tested on example app.
1 parent 510905e commit 09adf84

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

src/web/tools/GestureHandlerOrchestrator.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export default class GestureHandlerOrchestrator {
99

1010
private gestureHandlers: GestureHandler[] = [];
1111
private awaitingHandlers: GestureHandler[] = [];
12-
private handlersToCancel: GestureHandler[] = [];
1312

1413
private handlingChangeSemaphore = 0;
1514
private activationIndex = 0;
@@ -34,7 +33,6 @@ export default class GestureHandlerOrchestrator {
3433
public removeHandlerFromOrchestrator(handler: GestureHandler): void {
3534
this.gestureHandlers.splice(this.gestureHandlers.indexOf(handler), 1);
3635
this.awaitingHandlers.splice(this.awaitingHandlers.indexOf(handler), 1);
37-
this.handlersToCancel.splice(this.handlersToCancel.indexOf(handler), 1);
3836
}
3937

4038
private cleanupFinishedHandlers(): void {
@@ -177,17 +175,12 @@ export default class GestureHandlerOrchestrator {
177175
handler.setShouldResetProgress(true);
178176
handler.setActivationIndex(this.activationIndex++);
179177

180-
this.gestureHandlers.forEach((otherHandler) => {
181-
// Order of arguments is correct - we check whether current handler should cancel existing handlers
182-
183-
if (this.shouldHandlerBeCancelledBy(otherHandler, handler)) {
184-
this.handlersToCancel.push(otherHandler);
178+
for (let i = this.gestureHandlers.length - 1; i >= 0; --i) {
179+
if (this.shouldHandlerBeCancelledBy(this.gestureHandlers[i], handler)) {
180+
this.gestureHandlers[i].cancel();
185181
}
186-
});
187-
188-
for (let i = this.handlersToCancel.length - 1; i >= 0; --i) {
189-
this.handlersToCancel[i]?.cancel();
190182
}
183+
191184
this.awaitingHandlers.forEach((otherHandler) => {
192185
if (this.shouldHandlerBeCancelledBy(otherHandler, handler)) {
193186
otherHandler?.cancel();
@@ -212,8 +205,6 @@ export default class GestureHandlerOrchestrator {
212205
}
213206
}
214207
}
215-
216-
this.handlersToCancel = [];
217208
}
218209

219210
private addAwaitingHandler(handler: GestureHandler): void {

0 commit comments

Comments
 (0)