Détail du package

surf-timer

kcansari15MIT1.1.6

this code tracks consumed time in a page while considering idle time

page, time, tracker, consumed

readme

Surf-Timer

MIT License

Description

Tracks consumed time in a page while considering idle time and user activity.

Installation

 # With yarn
yarn add surf-timer

# With npm
npm i surf-timer

Example Usage

import { useSurfTimer } from "surf-timer";

function App() {
  const surfTime = useSurfTimer({
    idleTime: 2000,
    initialState: false,
    intervalTime: 1000,
    fn() {
      console.log("hello world");
    },
  });

  useEffect(() => {
    surfTime.interval.start();
    return surfTime.interval.stop;
  }, []);

  return (
    <div>
      <h2>Current Idle State: {surfTime.idle ? "true" : "false"}</h2>
      <h2>
        Current Interval State: {surfTime.interval.active ? "Start" : "Stop"}
      </h2>
    </div>
  );
}

export default App;

Definition

Parameters Description
idleTime Refers to the duration seconds of user inactivity.
initialState Initial state of idle (boolean)
intervalTime Amount of milliseconds between each tick
fn Function that is called at each interval tick
events Events that hook will listen

Custom Events

By default, the hook will listen to keypress, mousemove, touchmove, click and scrollevents to set idle status.

Return Object

surfTime.idle -> current idle status

surfTime.interval.start -> start interval

surfTime.interval.stop -> stop interval

surfTime.interval.toggle -> toggle interval

surtTime.interval.active -> current interval status

changelog

page-time-tracker

1.1.6

Patch Changes

  • 95b8b9e: readme file mistake is solved

1.1.5

Patch Changes

  • 312091a: readme is updated and events are become optional

1.1.4

Patch Changes

  • d8271a6: main hook is implemented

1.1.3

Patch Changes

  • e037250: repo url changed

1.1.2

Patch Changes

  • 693331f: hooks are implemented

1.1.1

Patch Changes

  • hooks are implemented

1.1.0

Minor Changes

  • c08e828: Fixed issue where dist folder was not being sent live

1.0.3

Patch Changes

  • Fixed issue where dist folder was not being sent live

  • f1e5afb: test 2

1.0.2

Patch Changes

  • 0500890: test 1

1.0.1

Patch Changes

  • 04a1b5a: initial commit