1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { ViewportScroller } from '@angular/common';
|
---|
9 | import { Injectable } from '@angular/core';
|
---|
10 | import { NavigationEnd, NavigationStart, Scroll } from './events';
|
---|
11 | import { Router } from './router';
|
---|
12 | export class RouterScroller {
|
---|
13 | constructor(router,
|
---|
14 | /** @docsNotRequired */ viewportScroller, options = {}) {
|
---|
15 | this.router = router;
|
---|
16 | this.viewportScroller = viewportScroller;
|
---|
17 | this.options = options;
|
---|
18 | this.lastId = 0;
|
---|
19 | this.lastSource = 'imperative';
|
---|
20 | this.restoredId = 0;
|
---|
21 | this.store = {};
|
---|
22 | // Default both options to 'disabled'
|
---|
23 | options.scrollPositionRestoration = options.scrollPositionRestoration || 'disabled';
|
---|
24 | options.anchorScrolling = options.anchorScrolling || 'disabled';
|
---|
25 | }
|
---|
26 | init() {
|
---|
27 | // we want to disable the automatic scrolling because having two places
|
---|
28 | // responsible for scrolling results race conditions, especially given
|
---|
29 | // that browser don't implement this behavior consistently
|
---|
30 | if (this.options.scrollPositionRestoration !== 'disabled') {
|
---|
31 | this.viewportScroller.setHistoryScrollRestoration('manual');
|
---|
32 | }
|
---|
33 | this.routerEventsSubscription = this.createScrollEvents();
|
---|
34 | this.scrollEventsSubscription = this.consumeScrollEvents();
|
---|
35 | }
|
---|
36 | createScrollEvents() {
|
---|
37 | return this.router.events.subscribe(e => {
|
---|
38 | if (e instanceof NavigationStart) {
|
---|
39 | // store the scroll position of the current stable navigations.
|
---|
40 | this.store[this.lastId] = this.viewportScroller.getScrollPosition();
|
---|
41 | this.lastSource = e.navigationTrigger;
|
---|
42 | this.restoredId = e.restoredState ? e.restoredState.navigationId : 0;
|
---|
43 | }
|
---|
44 | else if (e instanceof NavigationEnd) {
|
---|
45 | this.lastId = e.id;
|
---|
46 | this.scheduleScrollEvent(e, this.router.parseUrl(e.urlAfterRedirects).fragment);
|
---|
47 | }
|
---|
48 | });
|
---|
49 | }
|
---|
50 | consumeScrollEvents() {
|
---|
51 | return this.router.events.subscribe(e => {
|
---|
52 | if (!(e instanceof Scroll))
|
---|
53 | return;
|
---|
54 | // a popstate event. The pop state event will always ignore anchor scrolling.
|
---|
55 | if (e.position) {
|
---|
56 | if (this.options.scrollPositionRestoration === 'top') {
|
---|
57 | this.viewportScroller.scrollToPosition([0, 0]);
|
---|
58 | }
|
---|
59 | else if (this.options.scrollPositionRestoration === 'enabled') {
|
---|
60 | this.viewportScroller.scrollToPosition(e.position);
|
---|
61 | }
|
---|
62 | // imperative navigation "forward"
|
---|
63 | }
|
---|
64 | else {
|
---|
65 | if (e.anchor && this.options.anchorScrolling === 'enabled') {
|
---|
66 | this.viewportScroller.scrollToAnchor(e.anchor);
|
---|
67 | }
|
---|
68 | else if (this.options.scrollPositionRestoration !== 'disabled') {
|
---|
69 | this.viewportScroller.scrollToPosition([0, 0]);
|
---|
70 | }
|
---|
71 | }
|
---|
72 | });
|
---|
73 | }
|
---|
74 | scheduleScrollEvent(routerEvent, anchor) {
|
---|
75 | this.router.triggerEvent(new Scroll(routerEvent, this.lastSource === 'popstate' ? this.store[this.restoredId] : null, anchor));
|
---|
76 | }
|
---|
77 | /** @nodoc */
|
---|
78 | ngOnDestroy() {
|
---|
79 | if (this.routerEventsSubscription) {
|
---|
80 | this.routerEventsSubscription.unsubscribe();
|
---|
81 | }
|
---|
82 | if (this.scrollEventsSubscription) {
|
---|
83 | this.scrollEventsSubscription.unsubscribe();
|
---|
84 | }
|
---|
85 | }
|
---|
86 | }
|
---|
87 | RouterScroller.decorators = [
|
---|
88 | { type: Injectable }
|
---|
89 | ];
|
---|
90 | RouterScroller.ctorParameters = () => [
|
---|
91 | { type: Router },
|
---|
92 | { type: ViewportScroller },
|
---|
93 | { type: undefined }
|
---|
94 | ];
|
---|
95 | //# sourceMappingURL=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