MCPcopy Index your code
hub / github.com/angular/angular / scroll

Method scroll

adev/src/app/app-scroller.ts:97–125  ·  view source on GitHub ↗
(injector?: Injector)

Source from the content-addressed store, hash-verified

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}

Callers 2

forceTooltipScrollTopFunction · 0.45

Calls 4

afterNextRenderFunction · 0.90
destroyMethod · 0.65
scrollToPositionMethod · 0.45
scrollToAnchorMethod · 0.45

Tested by

no test coverage detected