3 examples of 'onscroll javascript' in JavaScript

Every line of 'onscroll javascript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
264onscroll: function onscroll() {
265 this.animate({
266 scrollTop: this.find('form').height()
267 }, 500);
268}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

18export function onScroll() {
19 let nav = getNav();
20 const headerHeight = getHeaderHeight();
21 if (!headerHeight) {
22 nav.classList.add("is-visible", "is-fixed");
23 return;
24 }
25
26 let currentTop = getScrollTop();
27 //check if user is scrolling up
28 if (currentTop < previousTop) {
29 //if scrolling up...
30 if (currentTop > 0 && nav.classList.contains("is-fixed")) {
31 nav.classList.add("is-visible");
32 } else {
33 nav.classList.remove("is-visible", "is-fixed");
34 }
35 } else if (currentTop > previousTop) {
36 //if scrolling down...
37 nav.classList.remove("is-visible");
38 if (currentTop > getHeaderHeight() && !nav.classList.contains("is-fixed"))
39 nav.classList.add("is-fixed");
40 }
41 previousTop = currentTop;
42}
63_onScroll() {
64
65 if (!this.state.scrolled) {
66 this.setState({scrolled: true});
67 this.eventEmitter.emit('stopAnimation');
68
69 }
70 if (this.props.onScroll) {
71 this.props.onScroll();
72 }
73}

Related snippets