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

Method consumeScrollEvents

packages/router/src/router_scroller.ts:106–126  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

104 }
105
106 private consumeScrollEvents() {
107 return this.transitions.events.subscribe((e) => {
108 if (!(e instanceof Scroll) || e.scrollBehavior === 'manual') return;
109 const instantScroll: ScrollOptions = {behavior: 'instant'};
110 // a popstate event. The pop state event will always ignore anchor scrolling.
111 if (e.position) {
112 if (this.options.scrollPositionRestoration === 'top') {
113 this.viewportScroller.scrollToPosition([0, 0], instantScroll);
114 } else if (this.options.scrollPositionRestoration === 'enabled') {
115 this.viewportScroller.scrollToPosition(e.position, instantScroll);
116 }
117 // imperative navigation "forward"
118 } else {
119 if (e.anchor && this.options.anchorScrolling === 'enabled') {
120 this.viewportScroller.scrollToAnchor(e.anchor);
121 } else if (this.options.scrollPositionRestoration !== 'disabled') {
122 this.viewportScroller.scrollToPosition([0, 0]);
123 }
124 }
125 });
126 }
127
128 private scheduleScrollEvent(
129 routerEvent: NavigationEnd | NavigationSkipped,

Callers 1

initMethod · 0.95

Calls 3

subscribeMethod · 0.65
scrollToPositionMethod · 0.45
scrollToAnchorMethod · 0.45

Tested by

no test coverage detected