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

Method withRootElement

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

* Sets an alternate drag root element. The root element is the element that will be moved as * the user is dragging. Passing an alternate root element is useful when trying to enable * dragging on an element that you might not have access to.

(rootElement: ElementRef<HTMLElement> | HTMLElement)

Source from the content-addressed store, hash-verified

493 * dragging on an element that you might not have access to.
494 */
495 withRootElement(rootElement: ElementRef<HTMLElement> | HTMLElement): this {
496 const element = coerceElement(rootElement);
497
498 if (element !== this._rootElement) {
499 this._removeRootElementListeners();
500 const renderer = this._renderer;
501 this._rootElementCleanups = this._ngZone.runOutsideAngular(() => [
502 renderer.listen(element, 'mousedown', this._pointerDown, activeEventListenerOptions),
503 renderer.listen(element, 'touchstart', this._pointerDown, passiveEventListenerOptions),
504 renderer.listen(element, 'dragstart', this._nativeDragStart, activeEventListenerOptions),
505 ]);
506 this._initialTransform = undefined;
507 this._rootElement = element;
508 }
509
510 if (typeof SVGElement !== 'undefined' && this._rootElement instanceof SVGElement) {
511 this._ownerSVGElement = this._rootElement.ownerSVGElement;
512 }
513
514 return this;
515 }
516
517 /**
518 * Element to which the draggable's position will be constrained.

Callers 2

constructorMethod · 0.95
_updateRootElementMethod · 0.80

Calls 3

coerceElementFunction · 0.90
listenMethod · 0.80

Tested by

no test coverage detected