What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-03-13 04:45:06
javascript touch scroll event
var lastTouch = null window.addEventListener('touchstart', function (event) { lastTouch = event.touches[0] }) window.addEventListener('touchend', function (event) { lastTouch = null }) window.addEventListener('touchmove', function (event) { var c... Add solution -
Javascript 2022-03-04 04:15:09
add update react pwa feature
//This from url https://stackoverflow.com/questions/56972246/how-to-update-reactjs-based-pwa-to-the-new-version window.addEventListener('activate', function(event) { event.waitUntil( caches.keys().then(function(cacheNames) { ... Add solution -
Other 2022-02-17 17:00:03
componentdidmount functional hook
import { useState, useEffect } from 'react'; function getWindowDimensions() { const { innerWidth: width, innerHeight: height } = window; return { width, height }; } export default function useWindowDimensions() { const [windowDimensions,... Add solution -
Javascript 2022-02-16 02:15:15
override print command javascript
function beforePrint() { console.log('Do something special before print'); } function afterPrint() { console.log('Do something after print'); } if (window.matchMedia) { window.matchMedia('print').addListener(function (mql) { if (mql.... Add solution -
Other 2022-02-12 14:30:09
height form the top to the element
window.addEventListener('load', function() { //get the element var elem = document.getElementById('test'); //get the distance scrolled on body (by default can be changed) var distanceScrolled = document.body.scrollTop; //create viewport offset o... Add solution -
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