commit 187394326a1ad4584cc9dfed5fd0c68e3c4ccb80
parent e763343bd2c0938b3b3fe5efea3b5b872f3a31a8
Author: MTRNord <mtrnord1@gmail.com>
Date: Thu, 15 Mar 2018 18:18:22 +0100
Try using fragment attribute
Diffstat:
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/app/tweet-list/tweet-list.component.ts b/src/app/tweet-list/tweet-list.component.ts
@@ -1,4 +1,4 @@
-import {Component, Input, OnInit} from '@angular/core';
+import {Component, Input, OnInit, AfterViewChecked} from '@angular/core';
import * as Raven from 'raven-js';
import {ApiService, TweetsEntity} from '../api.service';
import {Observable} from 'rxjs/Observable';
@@ -10,6 +10,7 @@ import 'rxjs/add/operator/take';
import 'rxjs/add/operator/concat';
import 'rxjs/add/observable/throw';
import {ToastrService} from 'ngx-toastr';
+import {ActivatedRoute} from '@angular/router';
@Component({
@@ -17,11 +18,12 @@ import {ToastrService} from 'ngx-toastr';
templateUrl: './tweet-list.component.html',
styleUrls: ['./tweet-list.component.scss']
})
-export class TweetListComponent implements OnInit {
+export class TweetListComponent implements OnInit, AfterViewChecked {
@Input() uuid;
data: (TweetsEntity)[];
+ private fragment: Observable<string>;
- constructor(private apiService: ApiService, private toastr: ToastrService) {
+ constructor(private apiService: ApiService, private toastr: ToastrService, private route: ActivatedRoute) {
Raven.captureBreadcrumb({
message: 'Showing Paper',
category: 'paper',
@@ -33,6 +35,15 @@ export class TweetListComponent implements OnInit {
ngOnInit() {
this.getYesterday();
+ this.route.fragment.subscribe(fragment => { this.fragment = fragment; });
+ }
+
+ ngAfterViewChecked(): void {
+ try {
+ if (this.fragment) {
+ document.querySelector('#' + this.fragment).scrollIntoView();
+ }
+ } catch (e) { }
}
getYesterday() {