{"id":21304987,"url":"https://github.com/maximilianmairinger/tweensvgpath","last_synced_at":"2025-07-11T21:30:55.024Z","repository":{"id":57382587,"uuid":"225085904","full_name":"maximilianMairinger/tweenSvgPath","owner":"maximilianMairinger","description":"High performance \u0026 lightweight tween interpolation for svg paths","archived":false,"fork":false,"pushed_at":"2020-09-23T21:51:57.000Z","size":136,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T09:06:09.448Z","etag":null,"topics":["animate","interpolate","morph","path","svg","tween"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/tween-svg-path","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maximilianMairinger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-01T00:10:54.000Z","updated_at":"2024-11-04T17:30:43.000Z","dependencies_parsed_at":"2022-09-01T04:02:06.519Z","dependency_job_id":null,"html_url":"https://github.com/maximilianMairinger/tweenSvgPath","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/maximilianMairinger/tweenSvgPath","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximilianMairinger%2FtweenSvgPath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximilianMairinger%2FtweenSvgPath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximilianMairinger%2FtweenSvgPath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximilianMairinger%2FtweenSvgPath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maximilianMairinger","download_url":"https://codeload.github.com/maximilianMairinger/tweenSvgPath/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maximilianMairinger%2FtweenSvgPath/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264902114,"owners_count":23680999,"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":["animate","interpolate","morph","path","svg","tween"],"created_at":"2024-11-21T16:16:33.953Z","updated_at":"2025-07-11T21:30:54.701Z","avatar_url":"https://github.com/maximilianMairinger.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tween svg-path\n\nHigh performance \u0026 lightweight tween interpolation for svg paths\n\n## Example\n\nThis takes an svg path element and interpolates it to the given path over the duration of 1000ms.\n\n```js\nimport tweenSvgPath from \"tweenSvgPath\"\n\nlet fromSvgElem = document.querySelector(\"#svg path\")\nlet toSvgPath   = \"[your to svg path]\"\nlet duration    = 1000\n\nlet tweeny = tweenSvgPath(fromSvgElem, toSvgPath, duration)\n```\n\nIf you like to manually control the update cycle, set the optional parameter `run` to false.\n\n```js\nlet run = false\n\nlet tweeny = tweenSvgPath(fromSvgElem, toSvgPath, duration, run)\nconsole.log(tweeny.update(500))\n```\n\nThis way you could sync the animation up to something like a scroll position.\n\nTo manually tween it over a timeline (like in the example above) use [animation-frame-delta](https://www.npmjs.com/package/animation-frame-delta) as it has been extensively tested to work well together.\n\n```js\nimport animationFrameDelta from \"animation-frame-delta\"\n\nanimationFrameDelta((progress) =\u003e {\n  tweeny.update(progress)\n}, duration)\n\n// or the more cool but less readable version\n\nanimationFrameDelta(tweeny.update.bind(tweeny))\n```\n\nAdditionally the distribution can be controlled as well. To do so, dont give a `SVGPathElement` as from parameter but a string.\n\n```js\nlet fromSvgPath = \"[your from svg path]\"\nlet toSvgPath   = \"[your to   svg path]\"\n\nlet tweeny = tweenSvgPath(fromSvgPath, toSvgPath, duration)\n\nconst elem = document.querySelector(\"#svg path\")\ntweeny.onUpdate((interpolatedSvg) =\u003e {\n  elem.setAttribute(\"d\", interpolatedSvg)\n})\n```\n\nPaths can be given in parsed fashion (as `type Segments = (string | number)[][]`) as well. The output will not be stringifyed to a svg path like in the examples above. \n\n\u003e Note: The libraries [parse-svg-path](https://www.npmjs.com/package/parse-svg-path), [abs-svg-path](https://www.npmjs.com/package/abs-svg-path) and [normalize-svg-path](https://www.npmjs.com/package/normalize-svg-path) provide parsing to the mentioned Segements type.\n\n```js\nimport * as parse from \"parse-svg-path\"\nimport * as abs from \"abs-svg-path\"\nimport * as normalize from \"normalize-svg-path\"\n\nlet fromPathSegments = normalize(abs(parse(\"[your from svg path]\")))\nlet toParsedSegments   = normalize(abs(parse(\"[your to   svg path]\")))\n\ntweenSvgPath(fromPathSegments, toParsedSegments, duration).onUpdate((interpolatedPathSegmenets) =\u003e {\n  console.log(interpolatedPathSegmenets)\n})\n```\n\n\n## Conribute\n\nAll feedback is appreciated. Create a pull request or write an issue.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaximilianmairinger%2Ftweensvgpath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaximilianmairinger%2Ftweensvgpath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaximilianmairinger%2Ftweensvgpath/lists"}