UNPKG

@guruhotel/aura-hooks

Version:

🪝 Hooks library designed by the Guruhotel team for Aura UI

1 lines 501 B
exports.__esModule=!0,exports.useIdle=function(r,n){const{events:o,initialState:s}={...t,...n},[c,u]=(0,e.useState)(s),i=(0,e.useRef)();return(0,e.useEffect)((()=>{const e=()=>{u(!1),i.current&&window.clearTimeout(i.current),i.current=window.setTimeout((()=>{u(!0)}),r)};return o.forEach((t=>document.addEventListener(t,e))),()=>{o.forEach((t=>document.removeEventListener(t,e)))}}),[r]),c};var e=require("react");const t={events:["keypress","mousemove","touchmove","click","scroll"],initialState:!0};