Skip to content
This repository was archived by the owner on Feb 5, 2022. It is now read-only.

Commit 0f6d9bd

Browse files
author
“Young
committed
fix a bug: made Scroll up when new page is opened(Home, Service, Contact and Blog).
1 parent 8a30b4e commit 0f6d9bd

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

src/pages/app-blog/app-blog.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, State, h } from '@stencil/core';
1+
import { Component, State, h, Build } from '@stencil/core';
22
import { BlogPost } from '../../model/blog-post.model';
33
import { BlogMeta } from '../../model/blog-meta.model';
44
import { BlogCategory } from '../../model/blog-category.model';
@@ -61,6 +61,9 @@ export class AppBlog {
6161
}
6262

6363
componentDidLoad() {
64+
if (Build.isBrowser) {
65+
window.scrollTo(0, 0);
66+
}
6467
const input = document.getElementById('blog-search');
6568
input.addEventListener('search', () => this.handleSearch(input.innerText));
6669

src/pages/app-contact/app-contact.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, State, Listen, Prop, h } from '@stencil/core';
1+
import { Component, State, Listen, Prop, h, Build } from '@stencil/core';
22
import { translate } from '../../services/translation.service';
33

44
@Component({
@@ -56,7 +56,10 @@ export class AppContact {
5656
}
5757

5858
componentDidLoad() {
59-
this.resetFormValues();
59+
if (Build.isBrowser) {
60+
this.resetFormValues();
61+
window.scrollTo(0, 0);
62+
}
6063
}
6164

6265
validateField(e) {

src/pages/app-home/app-home.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export class AppHome {
2828
}
2929

3030
componentDidLoad() {
31+
if (Build.isBrowser) {
32+
window.scrollTo(0, 0);
33+
}
3134
/* tslint:disable-next-line */
3235
window.addEventListener('scroll', () => {
3336
const innerPanel = document.getElementById('content-panel-inner');

src/pages/app-services/app-services.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
import { Component, h } from '@stencil/core';
1+
import { Component, h, Build } from '@stencil/core';
22

33
@Component({
44
tag: 'app-services',
55
styleUrl: 'app-services.scss',
66
})
77
export class AppServices {
8+
componentDidLoad() {
9+
if (Build.isBrowser) {
10+
window.scrollTo(0, 0);
11+
}
12+
}
813

914
changeMetadata() {
1015
// Change meta tags dynamically

0 commit comments

Comments
 (0)