Skip to content

Commit 24a7c6d

Browse files
authored
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.
1 parent 274416b commit 24a7c6d

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
@@ -367,8 +367,10 @@ export class DragRef<T = any> {
367367
this._removeRootElementListeners(this._rootElement);
368368
}
369369

370-
element.addEventListener('mousedown', this._pointerDown, activeEventListenerOptions);
371-
element.addEventListener('touchstart', this._pointerDown, passiveEventListenerOptions);
370+
this._ngZone.runOutsideAngular(() => {
371+
element.addEventListener('mousedown', this._pointerDown, activeEventListenerOptions);
372+
element.addEventListener('touchstart', this._pointerDown, passiveEventListenerOptions);
373+
});
372374
this._initialTransform = undefined;
373375
this._rootElement = element;
374376
}

0 commit comments

Comments
 (0)