commit c906243393456e9db6ad5371faa840c6d002437c
parent 440c7fd5add9d56ec44b6f04284eced3a6cccacf
Author: MTRNord <mtrnord1@gmail.com>
Date: Sun, 18 Mar 2018 17:58:54 +0100
Try to use directly Elements
Diffstat:
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/src/app/tweet-list/tweet-list.component.html b/src/app/tweet-list/tweet-list.component.html
@@ -8,12 +8,12 @@
</span>
</div>
<div style="z-index: 2;">
- <a (click)="goTo('#img'+i)" >
+ <a (click)="goTo(item, i)" >
<img *ngIf="item.image_urls && item.image_urls[0]" [src]="item.image_urls[0]" class="thumbnail">
</a>
<!-- lightbox container hidden with CSS -->
- <a (click)="goTo('#_')" class="lightbox" id="#img{{i}}">
+ <a href="#_" class="lightbox" id="#{{i}}">
<img src="http://insomnia.rest/images/screens/main.png">
</a>
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, ElementRef, Inject, Input, OnInit, ViewChild} from '@angular/core';
+import {Component, Input, OnInit, ViewChildren} from '@angular/core';
import * as Raven from 'raven-js';
import {ApiService, TweetsEntity} from '../api.service';
import {Observable} from 'rxjs/Observable';
@@ -10,8 +10,6 @@ import 'rxjs/add/operator/take';
import 'rxjs/add/operator/concat';
import 'rxjs/add/observable/throw';
import {ToastrService} from 'ngx-toastr';
-import {PageScrollInstance, PageScrollService} from 'ng2-page-scroll';
-import {DOCUMENT} from '@angular/common';
@Component({
@@ -22,11 +20,9 @@ import {DOCUMENT} from '@angular/common';
export class TweetListComponent implements OnInit {
@Input() uuid;
data: (TweetsEntity)[];
+ @ViewChildren
- @ViewChild('container')
- private container: ElementRef;
-
- constructor(private apiService: ApiService, private toastr: ToastrService, private pageScrollService: PageScrollService, @Inject(DOCUMENT) private document: any) {
+ constructor(private apiService: ApiService, private toastr: ToastrService) {
Raven.captureBreadcrumb({
message: 'Showing Paper',
category: 'paper',
@@ -36,10 +32,13 @@ export class TweetListComponent implements OnInit {
});
}
- public goTo(anchor: string): void {
- console.log(anchor);
- const pageScrollInstance: PageScrollInstance = PageScrollInstance.newInstance({document: this.document, scrollTarget: anchor, scrollingViews: [this.container.nativeElement]});
- this.pageScrollService.start(pageScrollInstance);
+ public goTo(el: HTMLElement[], which: string): void {
+ el.forEach((value: HTMLElement, index: number, array: HTMLElement[]) => {
+ if (value.id === which) {
+ console.log(value);
+ value.scrollIntoView();
+ }
+ });
}
ngOnInit() {