SupremeTechnopriest / react-idle-timer

User activity timer component
https://idletimer.dev
MIT License
1.15k stars 143 forks source link

⚡ Add PointerEvents types to EventType.ts. #292

Closed drecali closed 2 years ago

drecali commented 2 years ago

Closes #287 Added the pointer event types below to the event prop for useIdleTimer or withIdleTimer.

I don't personally use all these events but according to MDN, it seems like they're all valid and supported.

pointerover
pointerenter
pointerdown
pointermove
pointerup
pointercancel
pointerout
pointerleave
gotpointercapture
lostpointercapture

I was using the workaround below to add more events on a per-project basis, but it may not be easy for all users to implement. I think it's easier if this library supports valid event types according to the W3C specs.

- import { useIdleTimer } from 'react-idle-timer';
+ import { EVENTS, useIdleTimer } from 'react-idle-timer';

+ const timerEvents = [
+  'pointerup',
+  'pointermove'
+ ] as const;

  const { pause, resume, reset } = useIdleTimer({
    element: document,
    timeout: 2000,
-  events: ['pointerup', 'pointermove'],
+  events: timerEvents as unknown as EVENTS[],
  });

Please let me know if I missed anything. Thanks again for maintaining such a useful library!

vercel[bot] commented 2 years ago

Someone is attempting to deploy a commit to a Personal Account owned by @SupremeTechnopriest on Vercel.

@SupremeTechnopriest first needs to authorize it.