(injector?: Injector)
| 95 | } |
| 96 | |
| 97 | private scroll(injector?: Injector) { |
| 98 | if (!this._lastScrollEvent || !this.canScroll) { |
| 99 | return; |
| 100 | } |
| 101 | // Prevent double scrolling on the same event |
| 102 | this.canScroll = false; |
| 103 | const {anchor, position} = this._lastScrollEvent; |
| 104 | |
| 105 | // Don't scroll during rendering |
| 106 | const ref = afterNextRender( |
| 107 | { |
| 108 | write: () => { |
| 109 | if (position) { |
| 110 | this.viewportScroller.scrollToPosition(position); |
| 111 | } else if (anchor) { |
| 112 | this.viewportScroller.scrollToAnchor(anchor); |
| 113 | } else { |
| 114 | this.viewportScroller.scrollToPosition([0, 0]); |
| 115 | } |
| 116 | }, |
| 117 | }, |
| 118 | // Use the component injector when provided so that the manager can |
| 119 | // deregister the sequence once the component is destroyed. |
| 120 | {injector: injector ?? this.injector}, |
| 121 | ); |
| 122 | this.cancelScroll = () => { |
| 123 | ref.destroy(); |
| 124 | }; |
| 125 | } |
| 126 | } |
no test coverage detected