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