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

Method _bindEvents

src/cdk/menu/pointer-focus-tracker.ts:58–75  ·  view source on GitHub ↗

Binds the enter/exit events on all the items.

()

Source from the content-addressed store, hash-verified

56
57 /** Binds the enter/exit events on all the items. */
58 private _bindEvents() {
59 // TODO(crisbeto): this can probably be simplified by binding a single event on a parent node.
60 this._itemsSubscription = this._items.changes.pipe(startWith(this._items)).subscribe(() => {
61 this._cleanupEvents();
62 this._eventCleanups = [];
63 this._items.forEach(item => {
64 const element = item._elementRef.nativeElement;
65 this._eventCleanups!.push(
66 this._renderer.listen(element, 'mouseenter', () => {
67 (this.entered as Subject<T>).next(item);
68 }),
69 this._renderer.listen(element, 'mouseout', () => {
70 (this.exited as Subject<T>).next(item);
71 }),
72 );
73 });
74 });
75 }
76
77 /** Cleans up the currently-bound events. */
78 private _cleanupEvents() {

Callers 1

constructorMethod · 0.95

Calls 4

_cleanupEventsMethod · 0.95
listenMethod · 0.80
pushMethod · 0.65
nextMethod · 0.45

Tested by

no test coverage detected