Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102775941
app.component.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Feb 24, 02:03
Size
1 KB
Mime Type
text/x-java
Expires
Wed, Feb 26, 02:03 (2 d)
Engine
blob
Format
Raw Data
Handle
24426668
Attached To
R8244 Eawag_Swing_Weight_Elicitation
app.component.ts
View Options
import { Component, OnInit } from '@angular/core';
import { AuthenticationService } from './authentication.service';
import { Title } from '@angular/platform-browser';
import { Router, NavigationStart, NavigationEnd } from '@angular/router';
import { Location, PopStateEvent } from "@angular/common";
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent implements OnInit {
private lastPoppedUrl: string;
private yScrollStack: number[] = [];
constructor(public auth: AuthenticationService, private title: Title,private router: Router, private location: Location) {}
ngOnInit() {
this.title.setTitle('Admin');
this.location.subscribe((ev:PopStateEvent) => {
this.lastPoppedUrl = ev.url;
});
this.router.events.subscribe((ev:any) => {
if (ev instanceof NavigationStart) {
if (ev.url != this.lastPoppedUrl)
this.yScrollStack.push(window.scrollY);
} else if (ev instanceof NavigationEnd) {
if (ev.url == this.lastPoppedUrl) {
this.lastPoppedUrl = undefined;
window.scrollTo(0, this.yScrollStack.pop());
} else
window.scrollTo(0, 0);
}
});
}
}
Event Timeline
Log In to Comment