diff --git a/src/app/home/home.page.html b/src/app/home/home.page.html index 03c44f8..25409b9 100644 --- a/src/app/home/home.page.html +++ b/src/app/home/home.page.html @@ -21,7 +21,7 @@ + [ngClass]="{'active' : selectedArticle !== null}" #slides>
diff --git a/src/app/home/home.page.ts b/src/app/home/home.page.ts index 02f6ee7..829cb2e 100644 --- a/src/app/home/home.page.ts +++ b/src/app/home/home.page.ts @@ -1,4 +1,5 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, ViewChild } from '@angular/core'; +import { IonSlides } from '@ionic/angular'; @Component({ selector: 'app-home', @@ -6,6 +7,8 @@ import { Component, OnInit } from '@angular/core'; styleUrls: ['./home.page.scss'], }) export class HomePage implements OnInit { + @ViewChild('slides', {static: false}) slides: IonSlides; + selectedTab: string = 'news'; selectedArticle: number = null; myComment: string = ''; @@ -82,7 +85,7 @@ export class HomePage implements OnInit { } expandArticle(index: number) { - this.selectedArticle = index; + this.selectedArticle = index; this.slideOpts = { slidesPerView: 1, @@ -90,6 +93,10 @@ export class HomePage implements OnInit { slidesOffsetBefore: 0, slidesOffsetAfter: 0, }; + + setTimeout(() => { + this.slides.slideTo(index); + }, 200); } closeArticle() {