MCPcopy Create free account
hub / github.com/angular/components / _draggingStarted

Method _draggingStarted

src/cdk/drag-drop/drop-list-ref.ts:594–623  ·  view source on GitHub ↗

Starts the dragging sequence within the list.

()

Source from the content-addressed store, hash-verified

592
593 /** Starts the dragging sequence within the list. */
594 private _draggingStarted() {
595 const styles = this._container.style as DragCSSStyleDeclaration;
596 this.beforeStarted.next();
597 this._isDragging = true;
598
599 if (
600 (typeof ngDevMode === 'undefined' || ngDevMode) &&
601 // Prevent the check from running on apps not using an alternate container. Ideally we
602 // would always run it, but introducing it at this stage would be a breaking change.
603 this._container !== coerceElement(this.element)
604 ) {
605 for (const drag of this._draggables) {
606 if (!drag.isDragging() && drag.getVisibleElement().parentNode !== this._container) {
607 throw new Error(
608 'Invalid DOM structure for drop list. All items must be placed directly inside of the element container.',
609 );
610 }
611 }
612 }
613
614 // We need to disable scroll snapping while the user is dragging, because it breaks automatic
615 // scrolling. The browser seems to round the value based on the snapping points which means
616 // that we can't increment/decrement the scroll position.
617 this._initialScrollSnap = styles.msScrollSnapType || styles.scrollSnapType || '';
618 styles.scrollSnapType = styles.msScrollSnapType = 'none';
619 this._sortStrategy.start(this._draggables);
620 this._cacheParentPositions();
621 this._viewportScrollSubscription.unsubscribe();
622 this._listenToScrollEvents();
623 }
624
625 /** Caches the positions of the configured scrollable parents. */
626 private _cacheParentPositions() {

Callers 2

startMethod · 0.95
enterMethod · 0.95

Calls 7

_cacheParentPositionsMethod · 0.95
_listenToScrollEventsMethod · 0.95
coerceElementFunction · 0.90
getVisibleElementMethod · 0.80
startMethod · 0.65
nextMethod · 0.45
isDraggingMethod · 0.45

Tested by

no test coverage detected