What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-02-01 13:26:17
event listener for functional component
import React, { useEffect } from 'react'; const Component = (props) => { useEffect(() => { window.addEventListener('scroll', handleScroll); }); useEffect(() => { return () => { window.removeEventListener('scroll', handle... Add solution -
Javascript 2022-01-26 06:55:53
inject css with javascript
let isScrolled = false; window.addEventListener("scroll", () => { if (window.scrollY < 800) { let styleString1 = `body {background: silver;}` const style1 = document.createElement('style'); style1.textContent = styleStri... Add solution -
Javascript 2021-10-13 17:41:07
lax.js
//Install $ npm install lax.js import lax from 'lax.js' //Add to the html <script src="lib/lax.min.js" > // or via CDN <script src="https://cdn.jsdelivr.net/npm/lax.js" ></script> //Initialize it window.onload = fu... Add solution -
Javascript 2021-10-08 16:58:11
Scroll to the top of the page using JavaScript?
// Get The Id var topPage = document.getElementById(`top-page`) // On Click, Scroll to the Top of Page topPage.onclick = () => window.scrollTo({ top: 0, behavior: 'smooth' }) // On scroll, Show/Hide the button window.onscroll = () => { window.sc... Add solution
Best helpers
Ranking is empty