{"id":17941062,"url":"https://github.com/dldc-packages/humpf","last_synced_at":"2025-12-11T21:07:51.797Z","repository":{"id":42001643,"uuid":"252458794","full_name":"dldc-packages/humpf","owner":"dldc-packages","description":"📐  Damped Spring as a function of time","archived":false,"fork":false,"pushed_at":"2024-08-04T14:30:50.000Z","size":2581,"stargazers_count":25,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-07T14:06:34.575Z","etag":null,"topics":["anim","friction","springs","velocity"],"latest_commit_sha":null,"homepage":"https://humpf.etienne.tech/","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/dldc-packages.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"etienne-dldc"}},"created_at":"2020-04-02T13:10:13.000Z","updated_at":"2025-01-01T14:26:10.000Z","dependencies_parsed_at":"2023-02-14T06:15:41.839Z","dependency_job_id":"78d902cb-7c86-4be9-a4ee-e6c5eab19453","html_url":"https://github.com/dldc-packages/humpf","commit_stats":{"total_commits":156,"total_committers":3,"mean_commits":52.0,"dds":0.09615384615384615,"last_synced_commit":"bd3694d67beb2f4bd1bc823e22a32be5d6aa8256"},"previous_names":["dldc-packages/humpf","etienne-dldc/humpf"],"tags_count":51,"template":false,"template_full_name":null,"purl":"pkg:github/dldc-packages/humpf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dldc-packages%2Fhumpf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dldc-packages%2Fhumpf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dldc-packages%2Fhumpf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dldc-packages%2Fhumpf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dldc-packages","download_url":"https://codeload.github.com/dldc-packages/humpf/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dldc-packages%2Fhumpf/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264089581,"owners_count":23555764,"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":["anim","friction","springs","velocity"],"created_at":"2024-10-29T01:05:03.797Z","updated_at":"2025-12-11T21:07:46.427Z","avatar_url":"https://github.com/dldc-packages.png","language":"TypeScript","funding_links":["https://github.com/sponsors/etienne-dldc"],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/dldc-packages/humpf/blob/58777da6cea44176e102204587922d7231ea2cff/design/logo.png\" width=\"597\" alt=\"humpf logo\"\u003e\n\u003c/p\u003e\n\n# 📐 Humpf\n\n\u003e Damped Spring position as a function of time\n\n```bash\nnpm install @dldc/humpf\n```\n\n## What is this\n\nThis a library that let you animate using a\n[Damped Springs](http://www.ryanjuckett.com/programming/damped-springs/). The\nawesome thing about springs is that they can model all king of motions:\n\n- ✅ From A to B with a rebound at the end\n- ✅ From A to B smoothly\n- ✅ Decay (like pushing something)\n\n## Difference with other libraries\n\nMost library out there will model spring by updating a value: on each frame they\ncompute the forces applyed on the value and upate it accordingly. Humpf is\ndifferent because it does not update a value but give you a function that take\nthe **time** as parameter and return the **position** and **velocity** (speed)\nat that position in time.\n\n## Gist\n\n```ts\nimport { Spring } from \"@dldc/humpf\";\n\nconst spring = Spring();\n\nspring(0); // { pos: 0, vel: 0 }\nspring(100); //  { pos: 26.4241, vel: 36.7879  }\nspring(200); //  { pos: 59.3994, vel: 27.0670 }\nspring(300); //  { pos: 80.0851, vel: 14.9361 }\nspring(500); //  { pos: 95.9572, vel: 3.3689 }\nspring(1000); //  { pos: 99.95006, vel: 0.0453 }\nspring(10000); //  { pos: 100, vel: 0 }\n```\n\n## Options\n\nYou can pass different options to the spring to change it's behavior:\n\n```ts\n// all the options (see below for more details)\nSpring({\n  position: 0, // initial velocity\n  equilibrium: 100, // position to approach (aka \"to\")\n  velocity: 0, // initial velocity\n  angularFrequency: 1, // how fast does it move ?\n  dampingRatio: 1, // how much is it slowed down ?\n  timeStart: 0, // time at which the annimation should start\n  timeScale: 1 / 100, // [ADVANCED] change time scale\n});\n```\n\n### `position` (default `0`)\n\nThis is the initiale position of the spring: the value when it starts (at\n`timeStart`).\n\n### `equilibrium` (default `100`)\n\nThe equilibrium position of the spring: the value it will reach over time. If\nyour spring bounce it will occilate around this value.\n\n### `velocity` (default `0`)\n\nThe initial velocity of the spring. `0` mean it's stationary.\n\n**Example**: If your spring goes from `0` to `100`, a positive `velocity` mean\nit's already going up so it will go faster. A negative velocity means it's going\nin the oposite direction and will go down a little before going up.\n\n### `angularFrequency` (default `0`)\n\nThe angular frequency of your spring define how fast it wants to move. If you\nhave a very bouncy spring (not much friction), the angular frequency define how\nmany back and forth will happen.\n\n**Example**: `10` mean a lot of back and forth, so your spring will move fast.\n`0.5` is much lower so your spring will be slower\n\n### `dampingRatio` (default `1`)\n\nThe damping ratio define how much resistance (friction) is opposed to your\nspring.\\\nIf the damping ratio is less than `1` your spring will overshoot and bounce. If\nit's under `1` it will not.\\\nIf the damping ratio is `1` it will reach the equilibrium as fast as possible\nwithout bouncing.\n\n### `timeStart` (default `0`)\n\nThe time at which the spring should start.\\\nUsually you want to pass the current time to start a spring \"now\".\n\n**Note**: spring does not work in reverse, so you you try to get a value for a\ntime before `timeStart` it will return the initial state.\n\n### `timeScale` (default `1 / 100`)\n\nThe `timeScale` allow you to change how time is interpreted. The default value\n`1/100` will make your spring to take about a second to reach equilibrium. You\nprobably don't need to change this.\n\n## Math equations\n\nMost of the maths come from\nhttp://www.ryanjuckett.com/programming/damped-springs/.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdldc-packages%2Fhumpf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdldc-packages%2Fhumpf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdldc-packages%2Fhumpf/lists"}