Fix scrolling with hash in url
This commit is contained in:
parent
c7763eddd1
commit
64e0f8cf12
|
@ -35,6 +35,8 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked {
|
|||
|
||||
serverConfig: ServerConfig
|
||||
|
||||
private lastScrollHash: string
|
||||
|
||||
constructor (
|
||||
private viewportScroller: ViewportScroller,
|
||||
private route: ActivatedRoute,
|
||||
|
@ -74,7 +76,11 @@ export class AboutInstanceComponent implements OnInit, AfterViewChecked {
|
|||
}
|
||||
|
||||
ngAfterViewChecked () {
|
||||
if (window.location.hash) this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', ''))
|
||||
if (window.location.hash && window.location.hash !== this.lastScrollHash) {
|
||||
this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', ''))
|
||||
|
||||
this.lastScrollHash = window.location.hash
|
||||
}
|
||||
}
|
||||
|
||||
openContactModal () {
|
||||
|
|
|
@ -8,11 +8,17 @@ import { ViewportScroller } from '@angular/common'
|
|||
})
|
||||
|
||||
export class AboutPeertubeComponent implements AfterViewChecked {
|
||||
private lastScrollHash: string
|
||||
|
||||
constructor (
|
||||
private viewportScroller: ViewportScroller
|
||||
) {}
|
||||
|
||||
ngAfterViewChecked () {
|
||||
if (window.location.hash) this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', ''))
|
||||
if (window.location.hash && window.location.hash !== this.lastScrollHash) {
|
||||
this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', ''))
|
||||
|
||||
this.lastScrollHash = window.location.hash
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ export class MyAccountSettingsComponent implements OnInit, AfterViewChecked {
|
|||
userVideoQuotaUsedDaily = 0
|
||||
userVideoQuotaDailyPercentage = 15
|
||||
|
||||
private lastScrollHash: string
|
||||
|
||||
constructor (
|
||||
private viewportScroller: ViewportScroller,
|
||||
private userService: UserService,
|
||||
|
@ -64,7 +66,11 @@ export class MyAccountSettingsComponent implements OnInit, AfterViewChecked {
|
|||
}
|
||||
|
||||
ngAfterViewChecked () {
|
||||
if (window.location.hash) this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', ''))
|
||||
if (window.location.hash && window.location.hash !== this.lastScrollHash) {
|
||||
this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', ''))
|
||||
|
||||
this.lastScrollHash = window.location.hash
|
||||
}
|
||||
}
|
||||
|
||||
onAvatarChange (formData: FormData) {
|
||||
|
|
|
@ -123,6 +123,7 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|||
const scrollEvent = eventsObs.pipe(filter((e: Event): e is Scroll => e instanceof Scroll))
|
||||
|
||||
scrollEvent.subscribe(e => {
|
||||
console.log(e)
|
||||
if (e.position) {
|
||||
return this.viewportScroller.scrollToPosition(e.position)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue