{"id":15396987,"url":"https://github.com/ryanhefner/react-target-scroller","last_synced_at":"2026-04-17T08:04:00.198Z","repository":{"id":45272960,"uuid":"132648894","full_name":"ryanhefner/react-target-scroller","owner":"ryanhefner","description":"🎯 React component that smoothly scrolls to the target element passed in via props.","archived":false,"fork":false,"pushed_at":"2021-12-25T22:47:30.000Z","size":576,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-30T00:01:46.647Z","etag":null,"topics":["react","react-component","scroller","scrolling","target-scroller"],"latest_commit_sha":null,"homepage":"https://www.pkgstats.com/pkg:react-target-scroller","language":"JavaScript","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/ryanhefner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":"ryanhefner","open_collective":"ryanhefner","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2018-05-08T18:28:06.000Z","updated_at":"2023-03-04T04:12:37.000Z","dependencies_parsed_at":"2022-09-14T05:01:22.217Z","dependency_job_id":null,"html_url":"https://github.com/ryanhefner/react-target-scroller","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/ryanhefner/react-target-scroller","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanhefner%2Freact-target-scroller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanhefner%2Freact-target-scroller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanhefner%2Freact-target-scroller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanhefner%2Freact-target-scroller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanhefner","download_url":"https://codeload.github.com/ryanhefner/react-target-scroller/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanhefner%2Freact-target-scroller/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267639569,"owners_count":24119780,"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","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["react","react-component","scroller","scrolling","target-scroller"],"created_at":"2024-10-01T15:35:38.844Z","updated_at":"2026-04-17T08:04:00.150Z","avatar_url":"https://github.com/ryanhefner.png","language":"JavaScript","funding_links":["https://patreon.com/ryanhefner","https://opencollective.com/ryanhefner"],"categories":[],"sub_categories":[],"readme":"# 🎯 react-target-scroller\n\n![npm](https://img.shields.io/npm/v/react-target-scroller?style=flat-square)\n![NPM](https://img.shields.io/npm/l/react-target-scroller?style=flat-square)\n![npm](https://img.shields.io/npm/dt/react-target-scroller?style=flat-square)\n![Coveralls github](https://img.shields.io/coveralls/github/ryanhefner/react-target-scroller?style=flat-square)\n![CircleCI](https://img.shields.io/circleci/build/github/ryanhefner/react-target-scroller?style=flat-square)\n![Snyk Vulnerabilities for GitHub Repo](https://img.shields.io/snyk/vulnerabilities/github/ryanhefner/react-target-scroller?style=flat-square)\n\n\nReact component that smoothly scrolls to the `target` element passed in via props.\n\n## Install\n\nVia [npm](https://npmjs.com/package/react-target-scroller)\n\n```sh\nnpm install --save react-target-scroller\n```\n\nVia [Yarn](https://yarn.fyi/react-target-scroller)\n\n```sh\nyarn add react-target-scroller\n```\n\n## How to use\n\nThe `TargetScroller` is very configurable and designed to do a single thing well. I have another project, [`react-hash-handler`](https://github.com/ryanhefner/react-hash-handler), that pairs well with this component, but can easily be used alone, or coupled with your own components.\n\nBelow are the properties and callbacks that can be set on the component, along with an example of some general use.\n\n### Properties\n\n* `delay:Number` - The time in milliseconds to delay the scroll after the `target` has been set/changed. (default: `0`)\n\n* `direction:String` - The direction the `scrollingElement` will incremented/decremented in order to reach its target. The options are available via an `export` available from the component. Example: `import TargetScroller, {Direction} from 'react-target-scroller;` The options are, `Direction.VERTICAL` or `Direction.HORIZONTAL`. (default: `Direction.VERTICAL`)\n\n* `duration:Number` - The duration in milliseconds that the page will take to transition to the `target`. (default: `650`)\n\n* `ease:Func` - The easing function used to define the tween of the transition. `TargetScroller` uses [`tweenkle`](https://github.com/ryanhefner/tweenkle) and supports all the [easing equations](https://github.com/ryanhefner/tweenkle#easing) offered in that library, or you can write your own based on the ease spec. (default: `Quad.InOut`)\n\n* `offset:Number` - Number used to offset the scroll position. Useful for making sure fixed headers don’t cover up the target object.\n\n* `scrollingElement:[String || Element]` - The element that will be scrolled in order to reach the `target`. This is handy if you have a scrollable element in the page and want to target its children. (default: `'document.scrollingElement'`).\n\n* `target:[String || Element]` - The property that defines which element to scroll to. You can either supply an actual reference to the element, or a string that can target the element. (Note: If you supply a string, make sure it’s a string format that is supported by `querySelector`.)\n\n### Callbacks\n\n* `onTweenComplete:Func` - A function that is called when the scroll transition has finished.\n\n* `onTweenTick:Func` - A function that is called during the scroll transition on the way to the `target`.\n\n### Examples\n\n```js\nimport React, { Component } from 'react';\nimport TargetScroller from 'react-target-scroller';\n\n...\n\nclass ExampleComponent extends Compnonent {\n  constructor(props) {\n    super(props);\n\n    this.state = {\n      scrollTarget: null,\n    };\n\n    this.onNavLinkClick = this.onNavLinkClick.bind(this);\n  }\n\n  onNavLinkClick(evt) {\n    const hash = href.indexOf('#') \u003e -1 ? href.split('#')[1] : null;\n\n    if (!hash) {\n      return;\n    }\n\n    this.setState({\n      scrollTarget: `#${hash}`,\n    });\n  }\n\n  render() {\n    const {\n      scrollTarget,\n    } = this.state;\n\n    return (\n      \u003cdiv className=\"page-wrapper\"\u003e\n        \u003cnav\u003e\n          \u003cul\u003e\n            \u003cli\u003e\u003ca href=\"#overview\" onClick={this.onNavLinkClick}\u003eOverview\u003c/a\u003e\u003c/li\u003e\n            \u003cli\u003e\u003ca href=\"#about\" onClick={this.onNavLinkClick}\u003eAbout\u003c/a\u003e\u003c/li\u003e\n            \u003cli\u003e\u003ca href=\"#contact\" onClick={this.onNavLinkClick}\u003eContact\u003c/a\u003e\u003c/li\u003e\n          \u003c/ul\u003e\n        \u003c/nav\u003e\n        \u003cTargetScroller target={scrollTarget} /\u003e\n        ...\n        \u003csection id=\"overview\"\u003e\n          ...\n        \u003c/section\u003e\n        \u003csection id=\"about\"\u003e\n          ...\n        \u003c/section\u003e\n        \u003csection id=\"contact\"\u003e\n          ...\n        \u003c/section\u003e\n      \u003c/div\u003e\n    );\n  }\n}\n```\n\n## License\n\n[MIT](LICENSE) © [Ryan Hefner](https://www.ryanhefner.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanhefner%2Freact-target-scroller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanhefner%2Freact-target-scroller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanhefner%2Freact-target-scroller/lists"}