{"id":21241187,"url":"https://github.com/icyjoseph/use-easing","last_synced_at":"2026-03-17T23:36:48.880Z","repository":{"id":35014349,"uuid":"196698795","full_name":"icyJoseph/use-easing","owner":"icyJoseph","description":"Use Easings with React Hooks","archived":false,"fork":false,"pushed_at":"2023-03-04T04:19:32.000Z","size":1034,"stargazers_count":4,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-28T07:16:51.099Z","etag":null,"topics":["count-up","easing-functions","react","react-hooks","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/use-easing","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/icyJoseph.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-13T08:39:11.000Z","updated_at":"2025-06-27T16:16:37.000Z","dependencies_parsed_at":"2023-01-15T12:02:32.791Z","dependency_job_id":null,"html_url":"https://github.com/icyJoseph/use-easing","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/icyJoseph/use-easing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icyJoseph%2Fuse-easing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icyJoseph%2Fuse-easing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icyJoseph%2Fuse-easing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icyJoseph%2Fuse-easing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/icyJoseph","download_url":"https://codeload.github.com/icyJoseph/use-easing/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icyJoseph%2Fuse-easing/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264652625,"owners_count":23644291,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["count-up","easing-functions","react","react-hooks","typescript"],"created_at":"2024-11-21T00:54:56.218Z","updated_at":"2026-03-17T23:36:48.825Z","avatar_url":"https://github.com/icyJoseph.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# use-easing\n\n[![npm](https://img.shields.io/npm/dm/use-easing)]()\n\n\u003e Single dependency on React\n\n`use-easing` helps you ease a value using a React Hook.\n\nThis package also provides a few easings, you can specify any easing you want.\n\nThe package is written using TypeScript.\n\n\u003e Inspired by [React CountUp](https://github.com/glennreyes/react-countup)\n\nPackage size: :package: 2.75kb!\n\n## Install\n\nAvailable in NPM, as [use-easing](https://www.npmjs.com/package/use-easing)!\n\n```\nnpm install use-easing\n```\n\nor\n\n```\nyarn install use-easing\n```\n\n## Demo\n\n1. Clone repo `git clone git@github.com:icyJoseph/use-easing.git`\n2. Install dependencies `yarn` or `npm i`\n3. Run `yarn start:demo` or `npm run start:demo`\n4. Go to `localhost:3001`\n\n## Structure\n\nThe hook encapsulates a single `effect`, which kicks off a `process` that invokes `requestAnimationFrame`,\nuntil the easing value has arrived at its goal.\n\nThe `effect` depends on the `end` goal, the `duration` and the state of an internal `trigger`.\n\nThe hook returns, the `value` and a callback to alter the `trigger`.\n\n## Basic Props\n\n### `end`\n\nThe value will move toward this `end` goal, following a given easing curve and over a given period of time.\n\n### `duration`\n\nMeasured in seconds.\n\n```jsx\nfunction App() {\n  const { value } = useEasing({ end: 10, duration: 1 });\n  return value;\n}\n```\n\n## What does it do?\n\nIf you provide only the basic props, the component starts on mount and goes up to 10, over 1 second. By default it uses, the `easeInQuad`.\n\n```tsx\nfunction App() {\n  const { value } = useEasing\u003cnumber\u003e({ end: 10, duration: 1 });\n  return value;\n}\n```\n\nIf you are using TypeScript, bare in mind that easings are typed as shown.\n\n```ts\nexport const easeInQuad: easing = (\n  t: number,\n  b: number,\n  c: number,\n  d: number\n) =\u003e c * (t /= d) * t + b;\n```\n\nYou can also specify the type of value by passing a type parameter to `useEasing`. Or better yet, provide your own custom easing!\n\n\u003e t: current time, b: start, c: end - start, d: duration\n\n## Optional Props\n\n### `start`\n\nBy default the value starts at `0`, but this can be specified with the `start` prop.\n\n### `autoStart`\n\nThe `effect` will kick off the `process` as soon as possible, to prevent this, declare `autoStart` `false`.\n\n### `easingFn`\n\nThe easing function. This function is invoked on every `requestAnimationFrame`, and it calculates the current value value.\n\nMore on easing functions [here](http://robertpenner.com/easing/).\n\n### `formatFn`\n\nApplied to the outcome of the easing function. For example:\n\n```js\nconst floor = x =\u003e Math.floor(x);\nconst fixed = x =\u003e x.toFixed(2);\n```\n\nYou could even create a map where each number translates to some other symbol!\n\n### `onCleanUp`\n\nCalled when the `effect` is cleaned up.\n\n### `onPauseResume`\n\nCalled when the `process` is paused.\n\n### `onStart`\n\nCalled when the `process` starts.\n\n### `onEnd`\n\nCalled when the `process` ends.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficyjoseph%2Fuse-easing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficyjoseph%2Fuse-easing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficyjoseph%2Fuse-easing/lists"}