Skip to content

Commit

Permalink
Fix scroll when opening details
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelrahmanBayoumi committed Sep 24, 2023
1 parent 4ca38a1 commit c0ded06
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"ng-particles": "^3.12.0",
"ngx-image-cropper": "^7.0.2",
"rxjs": "~7.8.0",
"sweetalert2": "^11.7.27",
"sweetalert2": "^11.7.28",
"tslib": "^2.3.0",
"tsparticles-engine": "^2.12.0",
"tsparticles-slim": "^2.12.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Birthday } from 'src/app/birthday/model/birthday.model';
import * as fromApp from '../../../store/app.reducer';
import * as BirthdayActions from '../../../birthday/store/birthday.actions';
import { Store } from '@ngrx/store';
import { ActivatedRoute, Router } from '@angular/router';
import { ActivatedRoute, Router, NavigationEnd } from '@angular/router';
import { map, of, switchMap } from 'rxjs';
import { BirthdayStatistics } from 'src/app/birthday/model/birthday-statistics.model';
import Swal from 'sweetalert2';
Expand Down Expand Up @@ -39,6 +39,13 @@ export class BirthdayDetailsCompnent implements OnInit, OnDestroy {
}

ngOnInit(): void {
this.router.events.subscribe((event) => {
if (event instanceof NavigationEnd) {
// Scroll to the top of the page
window.scrollTo(0, 0);
}
});

this.storeSub0 = this.store
.select('birthdays')
.subscribe((birthdaysState) => {
Expand Down Expand Up @@ -96,6 +103,8 @@ export class BirthdayDetailsCompnent implements OnInit, OnDestroy {
});
}
});


}

onEditBirthday() {
Expand Down
2 changes: 1 addition & 1 deletion src/app/home/home.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<header>
<div *ngIf="!startSearch">
<h1 dir="auto" (click)="scrollToTop()">
<h1 dir="auto" routerLink="/">
<img src="/assets/images/logo.svg" alt="logo" />
</h1>
<button class="dark-icon-btn" (click)="onStartSearch()">
Expand Down
2 changes: 1 addition & 1 deletion src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
export const environment = {
production: true,
apiUrl: 'https://birthday-database.azurewebsites.net',
version: '0.0.13',
version: '0.0.14',
};
2 changes: 1 addition & 1 deletion src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
export const environment = {
production: false,
apiUrl: 'https://birthday-database.azurewebsites.net',
version: '0.0.13',
version: '0.0.14',
};

0 comments on commit c0ded06

Please sign in to comment.