Skip to content

Instantly share code, notes, and snippets.

@vitorpiovezam
Created September 13, 2019 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vitorpiovezam/c82083daac5b81ba43ac6583c39ff64d to your computer and use it in GitHub Desktop.
Save vitorpiovezam/c82083daac5b81ba43ac6583c39ff64d to your computer and use it in GitHub Desktop.
<a *ngIf="windowScrolled" (click)="scrollUp()">
<span class="scroll-top">
<
</span>
</a>
import { DOCUMENT } from '@angular/common';
windowScrolled: boolean;
lamp = faLightbulb;
constructor(
private localStorageService: LocalStorageService,
@Inject(DOCUMENT) private document: Document) {
@HostListener('window:scroll', [])
onWindowScroll() {
this.windowScrolled = window.pageYOffset > 250 ? true : false;
}
scrollUp() {
document.querySelector('nav').scrollIntoView({ behavior: 'smooth', block: 'start' });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment