Binds the enter/exit events on all the items.
()
| 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() { |
no test coverage detected