Skip to content

Commit 2f6e941

Browse files
crisbetojelbourn
authored andcommitted
perf(drag-drop): avoid unnecessary change detection on pointer down events (#18821)
When the drag&drop was initially implemented it had to trigger change detection immediately once dragging started so that the data bindings get updated correctly. After some time we introduced a threshold for dragging that also triggers its own change detection and makes the initial change detection unnecessary. Fixes #18726. (cherry picked from commit 24a7c6d)
1 parent 7c6be0e commit 2f6e941

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/cdk/drag-drop/drag-ref.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,10 @@ export class DragRef<T = any> {
364364
this._removeRootElementListeners(this._rootElement);
365365
}
366366

367-
element.addEventListener('mousedown', this._pointerDown, activeEventListenerOptions);
368-
element.addEventListener('touchstart', this._pointerDown, passiveEventListenerOptions);
367+
this._ngZone.runOutsideAngular(() => {
368+
element.addEventListener('mousedown', this._pointerDown, activeEventListenerOptions);
369+
element.addEventListener('touchstart', this._pointerDown, passiveEventListenerOptions);
370+
});
369371
this._initialTransform = undefined;
370372
this._rootElement = element;
371373
}

0 commit comments

Comments
 (0)