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

Method withHandles

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

Registers the handles that can be used to drag the element.

(handles: (HTMLElement | ElementRef<HTMLElement>)[])

Source from the content-addressed store, hash-verified

451
452 /** Registers the handles that can be used to drag the element. */
453 withHandles(handles: (HTMLElement | ElementRef<HTMLElement>)[]): this {
454 this._handles = handles.map(handle => coerceElement(handle));
455 this._handles.forEach(handle => toggleNativeDragInteractions(handle, this.disabled));
456 this._toggleNativeDragInteractions();
457
458 // Delete any lingering disabled handles that may have been destroyed. Note that we re-create
459 // the set, rather than iterate over it and filter out the destroyed handles, because while
460 // the ES spec allows for sets to be modified while they're being iterated over, some polyfills
461 // use an array internally which may throw an error.
462 const disabledHandles = new Set<HTMLElement>();
463 this._disabledHandles.forEach(handle => {
464 if (this._handles.indexOf(handle) > -1) {
465 disabledHandles.add(handle);
466 }
467 });
468 this._disabledHandles = disabledHandles;
469 return this;
470 }
471
472 /**
473 * Registers the template that should be used for the drag preview.

Callers 1

_setupHandlesListenerMethod · 0.80

Calls 4

coerceElementFunction · 0.90
addMethod · 0.45

Tested by

no test coverage detected