[Counts | Trunk]: Add smooth-scroll
This commit is contained in:
parent
7c9d1cb796
commit
436a6099ad
|
@ -16,7 +16,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<a class="uk-visible@l next uk-flex uk-flex-middle" (click)="goTo('architecture')">
|
<a class="uk-visible@l next uk-flex uk-flex-middle" routerLink="./" fragment="architecture">
|
||||||
Architecture
|
Architecture
|
||||||
<icon name="arrow_down" [flex]="true" class="uk-margin-left"></icon>
|
<icon name="arrow_down" [flex]="true" class="uk-margin-left"></icon>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -51,11 +51,6 @@ export class AboutComponent implements OnInit, OnDestroy {
|
||||||
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
||||||
this.subs.push(this._piwikService.trackView(this.properties, this.title).subscribe());
|
this.subs.push(this._piwikService.trackView(this.properties, this.title).subscribe());
|
||||||
}
|
}
|
||||||
this.subs.push(this.route.fragment.subscribe(fragment => {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.goTo(fragment);
|
|
||||||
}, 100);
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngOnDestroy() {
|
public ngOnDestroy() {
|
||||||
|
@ -65,13 +60,4 @@ export class AboutComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
goTo(id: string) {
|
|
||||||
const yOffset = -100;
|
|
||||||
const element = document.getElementById(id);
|
|
||||||
if(element) {
|
|
||||||
const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset;
|
|
||||||
window.scrollTo({top: y, behavior: 'smooth'});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
</schema2jsonld>
|
</schema2jsonld>
|
||||||
<div class="analytics">
|
<div class="analytics">
|
||||||
<div *ngIf="countryFb" class="uk-container uk-text-center countries">
|
<div *ngIf="countryFb" class="uk-container uk-text-center countries">
|
||||||
<a class="uk-visible@l next uk-flex uk-flex-middle uk-text-uppercase" (click)="goTo('graph-analysis')">
|
<a class="uk-visible@l next uk-flex uk-flex-middle uk-text-uppercase" routerLink="./" fragment="graph-analysis">
|
||||||
Graph Analysis
|
Graph Analysis
|
||||||
<icon name="arrow_down" [flex]="true" class="uk-margin-left"></icon>
|
<icon name="arrow_down" [flex]="true" class="uk-margin-left"></icon>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -59,11 +59,6 @@ export class AnalyticsComponent implements OnInit, OnDestroy {
|
||||||
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
||||||
this.subs.push(this._piwikService.trackView(this.properties, this.title).subscribe());
|
this.subs.push(this._piwikService.trackView(this.properties, this.title).subscribe());
|
||||||
}
|
}
|
||||||
this.subs.push(this.route.fragment.subscribe(fragment => {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.goTo(fragment);
|
|
||||||
}, 100);
|
|
||||||
}));
|
|
||||||
this.init();
|
this.init();
|
||||||
this.search(true);
|
this.search(true);
|
||||||
for(let i = 0; i < 3; i++) {
|
for(let i = 0; i < 3; i++) {
|
||||||
|
@ -188,15 +183,6 @@ export class AnalyticsComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
goTo(id: string) {
|
|
||||||
const yOffset = -100;
|
|
||||||
const element = document.getElementById(id);
|
|
||||||
if(element) {
|
|
||||||
const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset;
|
|
||||||
window.scrollTo({top: y, behavior: 'smooth'});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public getSafeUrl(url: string): SafeUrl {
|
public getSafeUrl(url: string): SafeUrl {
|
||||||
return this.sanitizer.bypassSecurityTrustResourceUrl(url);
|
return this.sanitizer.bypassSecurityTrustResourceUrl(url);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnDestroy, OnInit} from '@angular/core';
|
||||||
import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
|
import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
|
||||||
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
||||||
import {User} from './openaireLibrary/login/utils/helper.class';
|
import {User} from './openaireLibrary/login/utils/helper.class';
|
||||||
import {properties} from '../environments/environment';
|
import {properties} from '../environments/environment';
|
||||||
import {LayoutService} from './services/layout.service';
|
import {LayoutService} from './services/layout.service';
|
||||||
import {Header} from './openaireLibrary/sharedComponents/navigationBar.component';
|
import {Header} from './openaireLibrary/sharedComponents/navigationBar.component';
|
||||||
|
import {SmoothScroll} from './openaireLibrary/utils/smooth-scroll';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app',
|
selector: 'app',
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
})
|
})
|
||||||
|
|
||||||
export class AppComponent implements OnInit {
|
export class AppComponent implements OnInit, OnDestroy {
|
||||||
title = 'Metadata Registry Service';
|
title = 'Metadata Registry Service';
|
||||||
userMenuItems: MenuItem[] = [];
|
userMenuItems: MenuItem[] = [];
|
||||||
menuItems: RootMenuItem [] = [];
|
menuItems: RootMenuItem [] = [];
|
||||||
|
@ -24,7 +25,8 @@ export class AppComponent implements OnInit {
|
||||||
header: Header;
|
header: Header;
|
||||||
logoPath: string = 'assets/common-assets/';
|
logoPath: string = 'assets/common-assets/';
|
||||||
|
|
||||||
constructor(private layoutService: LayoutService) {}
|
constructor(private layoutService: LayoutService,
|
||||||
|
private smoothScroll: SmoothScroll) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.logInUrl = this.properties.loginUrl;
|
this.logInUrl = this.properties.loginUrl;
|
||||||
|
@ -79,4 +81,8 @@ export class AppComponent implements OnInit {
|
||||||
}].concat(this.menuItems);
|
}].concat(this.menuItems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnDestroy() {
|
||||||
|
this.smoothScroll.clearSubscriptions();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,8 @@ const appRoutes: Routes = [
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [RouterModule.forRoot(appRoutes, {
|
imports: [RouterModule.forRoot(appRoutes, {
|
||||||
preloadingStrategy: PreloadAllModules,
|
preloadingStrategy: PreloadAllModules,
|
||||||
scrollPositionRestoration: 'top'
|
onSameUrlNavigation: "reload",
|
||||||
|
relativeLinkResolution: 'corrected'
|
||||||
})],
|
})],
|
||||||
exports: [RouterModule]
|
exports: [RouterModule]
|
||||||
})
|
})
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
<icon name="arrow_right" ratio="0.8" class="space"></icon>
|
<icon name="arrow_right" ratio="0.8" class="space"></icon>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<a class="uk-visible@l next uk-flex uk-flex-middle" (click)="goTo('apis')">
|
<a class="uk-visible@l next uk-flex uk-flex-middle" routerLink="./" fragment="apis">
|
||||||
APIs AND REPORTS
|
APIs AND REPORTS
|
||||||
<icon name="arrow_down" [flex]="true" class="uk-margin-left"></icon>
|
<icon name="arrow_down" [flex]="true" class="uk-margin-left"></icon>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -49,11 +49,6 @@ export class ResourcesComponent implements OnInit, OnDestroy {
|
||||||
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
|
||||||
this.subs.push(this._piwikService.trackView(this.properties, this.title).subscribe());
|
this.subs.push(this._piwikService.trackView(this.properties, this.title).subscribe());
|
||||||
}
|
}
|
||||||
this.subs.push(this.route.fragment.subscribe(fragment => {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.goTo(fragment);
|
|
||||||
}, 100);
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ngOnDestroy() {
|
public ngOnDestroy() {
|
||||||
|
@ -63,13 +58,4 @@ export class ResourcesComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
goTo(id: string) {
|
|
||||||
const yOffset = -100;
|
|
||||||
const element = document.getElementById(id);
|
|
||||||
if(element) {
|
|
||||||
const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset;
|
|
||||||
window.scrollTo({top: y, behavior: 'smooth'});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,4 +27,5 @@
|
||||||
<body>
|
<body>
|
||||||
<app></app>
|
<app></app>
|
||||||
</body>
|
</body>
|
||||||
|
<script src="https://unpkg.com/smoothscroll-polyfill@0.4.3/dist/smoothscroll.min.js"></script>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -26,4 +26,5 @@
|
||||||
<body>
|
<body>
|
||||||
<app></app>
|
<app></app>
|
||||||
</body>
|
</body>
|
||||||
|
<script src="https://unpkg.com/smoothscroll-polyfill@0.4.3/dist/smoothscroll.min.js"></script>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue