Skip to content

Commit

Permalink
Merge pull request #20 from 4Furki4/daily-word-and-phrase
Browse files Browse the repository at this point in the history
add: scrollToTop when anchor el clicked.
  • Loading branch information
4Furki4 authored Jun 9, 2023
2 parents 1a7e5fa + 19d43bb commit be27cdd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ <h2 class="card__title">Bir Kelime</h2>
<div class="card--inner">
<div class="card__word">
<h3>
<a [routerLink]="word.madde">{{word.madde}}</a>
<a (click)="scrollToTop()" [routerLink]="word.madde">{{word.madde}}</a>
</h3>
</div>
<div class="card__definition">
Expand All @@ -19,7 +19,7 @@ <h2 class="card__title">Bir Deyim-Atasözü</h2>
<div class="card--inner">
<div class="card__word">
<h3>
<a [routerLink]="phrase.madde">{{phrase.madde}}</a>
<a (click)="scrollToTop()" [routerLink]="phrase.madde">{{phrase.madde}}</a>
</h3>
</div>
<div class="card__definition">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { animate, style, transition, trigger } from '@angular/animations';
import { Component, Input } from '@angular/core';
import { Component, Host, HostListener, Input } from '@angular/core';
import { Kelime, Atasoz } from 'src/app/models/home-content-response';
const enterSlideInRight = trigger('enterSlideInRight', [
transition(':enter', [
Expand All @@ -22,6 +22,15 @@ const enterSlideInLeft = trigger('enterSlideInLeft', [
export class DailyWordAndPhraseComponent {
constructor() {

}
position: number = 0;
scrollToTop() {
const isPortrait = window.innerWidth < window.innerHeight;
if (isPortrait) {
setTimeout(() => {
window.scrollTo({ top: 0, behavior: 'smooth' })
}, 100)
}
}
@Input('kelime') word!: Kelime
@Input('atasozu') phrase!: Atasoz;
Expand Down

1 comment on commit be27cdd

@vercel
Copy link

@vercel vercel bot commented on be27cdd Jun 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.