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

Method withElementContainer

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

* Configures the drop list so that a different element is used as the container for the * dragged items. This is useful for the cases when one might not have control over the * full DOM that sets up the dragging. * Note that the alternate container needs to be a descendant of the drop list.

(container: HTMLElement)

Source from the content-addressed store, hash-verified

409 * @param container New element container to be assigned.
410 */
411 withElementContainer(container: HTMLElement): this {
412 if (container === this._container) {
413 return this;
414 }
415
416 const element = coerceElement(this.element);
417
418 if (
419 (typeof ngDevMode === 'undefined' || ngDevMode) &&
420 container !== element &&
421 !element.contains(container)
422 ) {
423 throw new Error(
424 'Invalid DOM structure for drop list. Alternate container element must be a descendant of the drop list.',
425 );
426 }
427
428 const oldContainerIndex = this._scrollableElements.indexOf(this._container);
429 const newContainerIndex = this._scrollableElements.indexOf(container);
430
431 if (oldContainerIndex > -1) {
432 this._scrollableElements.splice(oldContainerIndex, 1);
433 }
434
435 if (newContainerIndex > -1) {
436 this._scrollableElements.splice(newContainerIndex, 1);
437 }
438
439 if (this._sortStrategy) {
440 this._sortStrategy.withElementContainer(container);
441 }
442
443 this._cachedShadowRoot = null;
444 this._scrollableElements.unshift(container);
445 this._container = container;
446 return this;
447 }
448
449 /** Gets the scrollable parents that are registered with this drop container. */
450 getScrollableParents(): readonly HTMLElement[] {

Callers

nothing calls this directly

Calls 2

coerceElementFunction · 0.90
withElementContainerMethod · 0.65

Tested by

no test coverage detected