Angular: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Zeile 22: | Zeile 22: | ||
== Menü beim Scrollen ausblenden == | == Menü beim Scrollen ausblenden == | ||
<pre> | |||
import { ..., HostListener, ... } from '@angular/core'; | |||
</pre> | |||
<pre> | |||
@HostListener('window:scroll', ['$event']) | |||
scrollHandler(event) { | |||
const currentScrollPos = window.pageYOffset; | |||
if ((currentScrollPos < 55) || (this.prevScrollpos > currentScrollPos)) { | |||
document.getElementById('nav-bar').style.top = '0'; | |||
} else { | |||
document.getElementById('nav-bar').style.top = '-100px'; | |||
} | |||
this.prevScrollpos = currentScrollPos; | |||
} | |||
</pre> | |||
=== Links === | === Links === |
Version vom 5. September 2018, 12:00 Uhr
Icons
npm install font-awesome --save
"styles": [ ... "node_modules/font-awesome/css/font-awesome.min.css", ... ],
... class="fa fa-user icon" ...
Links
Menü beim Scrollen ausblenden
import { ..., HostListener, ... } from '@angular/core';
@HostListener('window:scroll', ['$event']) scrollHandler(event) { const currentScrollPos = window.pageYOffset; if ((currentScrollPos < 55) || (this.prevScrollpos > currentScrollPos)) { document.getElementById('nav-bar').style.top = '0'; } else { document.getElementById('nav-bar').style.top = '-100px'; } this.prevScrollpos = currentScrollPos; }
Links
https://www.w3schools.com/howto/howto_js_navbar_hide_scroll.asp
Links
https://www.w3schools.com/angular/default.asp
Zurück zu JavaScript