aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+about/about-peertube/about-peertube.component.ts
blob: b175a41bca37857547dc28887ad6a33e9be606c0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { Component, AfterViewChecked } from '@angular/core'
import { ViewportScroller } from '@angular/common'

@Component({
  selector: 'my-about-peertube',
  templateUrl: './about-peertube.component.html',
  styleUrls: [ './about-peertube.component.scss' ]
})

export class AboutPeertubeComponent implements AfterViewChecked {
  private lastScrollHash: string

  constructor (
    private viewportScroller: ViewportScroller
  ) {}

  ngAfterViewChecked () {
    if (window.location.hash && window.location.hash !== this.lastScrollHash) {
      this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', ''))

      this.lastScrollHash = window.location.hash
    }
  }
}