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

Method _startDragSequence

src/cdk/drag-drop/drag-ref.ts:888–962  ·  view source on GitHub ↗

Starts the dragging sequence.

(event: MouseEvent | TouchEvent)

Source from the content-addressed store, hash-verified

886
887 /** Starts the dragging sequence. */
888 private _startDragSequence(event: MouseEvent | TouchEvent) {
889 if (isTouchEvent(event)) {
890 this._lastTouchEventTime = Date.now();
891 }
892
893 this._toggleNativeDragInteractions();
894
895 // Needs to happen before the root element is moved.
896 const shadowRoot = this._getShadowRoot();
897 const dropContainer = this._dropContainer;
898
899 if (shadowRoot) {
900 // In some browsers the global `selectstart` that we maintain in the `DragDropRegistry`
901 // doesn't cross the shadow boundary so we have to prevent it at the shadow root (see #28792).
902 this._ngZone.runOutsideAngular(() => {
903 this._cleanupShadowRootSelectStart = this._renderer.listen(
904 shadowRoot,
905 'selectstart',
906 shadowDomSelectStart,
907 activeCapturingEventOptions,
908 );
909 });
910 }
911
912 if (dropContainer) {
913 const element = this._rootElement;
914 const parent = element.parentNode as HTMLElement;
915 const placeholder = (this._placeholder = this._createPlaceholderElement());
916 const marker = (this._marker =
917 this._marker ||
918 this._document.createComment(
919 typeof ngDevMode === 'undefined' || ngDevMode ? 'cdk-drag-marker' : '',
920 ));
921
922 // Insert a marker node so that we can restore the element's position in the DOM.
923 parent.insertBefore(marker, element);
924
925 // There's no risk of transforms stacking when inside a drop container so
926 // we can keep the initial transform up to date any time dragging starts.
927 this._initialTransform = element.style.transform || '';
928
929 // Create the preview after the initial transform has
930 // been cached, because it can be affected by the transform.
931 this._preview = new PreviewRef(
932 this._document,
933 this._rootElement,
934 this._direction,
935 this._initialDomRect!,
936 this._previewTemplate || null,
937 this.previewClass || null,
938 this._pickupPositionOnPage,
939 this._initialTransform,
940 this._config.zIndex || 1000,
941 this._renderer,
942 );
943 this._preview.attach(this._getPreviewInsertionPoint(parent, shadowRoot));
944
945 // We move the element out at the end of the body and we make it hidden, because keeping it in

Callers 1

DragRefClass · 0.95

Calls 13

_getShadowRootMethod · 0.95
toggleVisibilityFunction · 0.90
isTouchEventFunction · 0.85
listenMethod · 0.80
cacheMethod · 0.80
getScrollableParentsMethod · 0.80
attachMethod · 0.65
startMethod · 0.65
getItemIndexMethod · 0.65

Tested by

no test coverage detected