{"_id":"react-router-scroll-4","_rev":"6-a8a5fb77df01cb31c4349b2b3b8ce726","name":"react-router-scroll-4","description":"React Router 4 scroll management","dist-tags":{"latest":"1.0.0-beta.2"},"versions":{"1.0.0-beta.1":{"name":"react-router-scroll-4","version":"1.0.0-beta.1","description":"React Router 4 scroll management","files":["lib"],"main":"lib/react-router-scroll-4.js","module":"lib/react-router-scroll-4.es.js","scripts":{"build":"npm run build-legacy && npm run build-modern","build-legacy":"rollup -c rollup.config.js","build-modern":"rollup -c rollup.es.config.js","lint":"eslint src test src/*.js","prepublish":"npm run build","tdd":"cross-env NODE_ENV=test karma start","test":"npm run lint -- --fix && npm run testonly","testonly":"npm run tdd -- --single-run"},"repository":{"type":"git","url":"git+https://github.com/ytase/react-router-scroll"},"keywords":["react","react router","scroll"],"author":{"name":"Jimmy Jia"},"license":"MIT","bugs":{"url":"https://github.com/ytase/react-router-scroll/issues"},"homepage":"https://github.com/ytase/react-router-scroll#readme","dependencies":{"babel-eslint":"^8.0.1","scroll-behavior":"^0.9.1","warning":"^3.0.0"},"peerDependencies":{"prop-types":"^15.6.0","react":"^15.0.0 || ^16.0.0","react-dom":"^15.0.0 || ^16.0.0","react-router-dom":"^4.0"},"devDependencies":{"babel-core":"^6.26.0","babel-plugin-dev-expression":"^0.2.1","babel-plugin-external-helpers":"^6.22.0","babel-plugin-transform-class-properties":"^6.24.1","babel-polyfill":"^6.16.0","babel-preset-env":"^1.6.1","babel-preset-react":"^6.16.0","chai":"^4.1.2","cross-env":"^3.1.3","dom-helpers":"^3.0.0","eslint":"^3.9.1","eslint-config-4catalyzer-react":"^0.1.3","eslint-plugin-import":"^1.16.0","eslint-plugin-jsx-a11y":"^2.2.3","eslint-plugin-react":"^6.5.0","history":"^4.7.2","karma":"^1.3.0","karma-chrome-launcher":"^2.0.0","karma-firefox-launcher":"^1.0.0","karma-mocha":"^1.2.0","karma-mocha-reporter":"^2.2.0","karma-rollup-preprocessor":"^5.0.1","karma-sinon-chai":"^1.3.2","karma-sourcemap-loader":"^0.3.7","mocha":"^4.0.1","react":"^16.0.0","react-dom":"^16.0.0","react-router-dom":"^4.0","rollup":"^0.50.0","rollup-plugin-babel":"^3.0.2","rollup-plugin-commonjs":"^8.2.4","rollup-plugin-node-resolve":"^3.0.0","rollup-plugin-replace":"^2.0.0","sinon":"^4.0.1","sinon-chai":"^2.14.0"},"licenseText":"The MIT License (MIT)\n\nCopyright (c) 2016 Jimmy Jia\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"react-router-scroll-4@1.0.0-beta.1","dist":{"shasum":"b1838c6e67b9fe64db33176958e88836e10bc4ce","tarball":"https://registry.npmjs.org/react-router-scroll-4/-/react-router-scroll-4-1.0.0-beta.1.tgz","integrity":"sha512-ST3uLgQ4cmwdu122ERtXRga++Gv79R2S9abgLcDI4Q4UuOSsxcYNUIhAL2fhq/MbVU4yAS+Y6QPrLTO/+KEqAw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD2xVruD2k2XMAGfV90YtWzR9ilFWhYumX/E9SZZKBT2wIhAKdOhVsmBsGJ/ocB66ehoiz5b6NQc3CaWJ8L5Dpr9aJh"}]},"maintainers":[{"name":"mijamo","email":"gourlaouen.mikael@gmail.com"}],"_npmUser":{"name":"mijamo","email":"gourlaouen.mikael@gmail.com"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-router-scroll-4-1.0.0-beta.1.tgz_1508851204987_0.21608324721455574"},"directories":{}},"1.0.0-beta.2":{"name":"react-router-scroll-4","version":"1.0.0-beta.2","description":"React Router 4 scroll management","files":["lib"],"main":"lib/react-router-scroll-4.js","module":"lib/react-router-scroll-4.es.js","scripts":{"build":"npm run build-legacy && npm run build-modern","build-legacy":"rollup -c rollup.config.js","build-modern":"rollup -c rollup.es.config.js","lint":"eslint src test src/*.js","prepublish":"npm run build","tdd":"cross-env NODE_ENV=test karma start","test":"npm run lint -- --fix && npm run testonly","testonly":"npm run tdd -- --single-run"},"repository":{"type":"git","url":"git+https://github.com/ytase/react-router-scroll.git"},"keywords":["react","react router","scroll"],"author":{"name":"Jimmy Jia"},"license":"MIT","bugs":{"url":"https://github.com/ytase/react-router-scroll/issues"},"homepage":"https://github.com/ytase/react-router-scroll#readme","dependencies":{"scroll-behavior":"^0.9.1","warning":"^3.0.0"},"peerDependencies":{"prop-types":"^15.6.0","react":"^15.0.0 || ^16.0.0","react-dom":"^15.0.0 || ^16.0.0","react-router-dom":"^4.0"},"devDependencies":{"babel-core":"^6.26.0","babel-eslint":"^8.0.1","babel-plugin-dev-expression":"^0.2.1","babel-plugin-external-helpers":"^6.22.0","babel-plugin-transform-class-properties":"^6.24.1","babel-polyfill":"^6.16.0","babel-preset-env":"^1.6.1","babel-preset-react":"^6.16.0","chai":"^4.1.2","cross-env":"^3.1.3","dom-helpers":"^3.0.0","eslint":"^3.9.1","eslint-config-4catalyzer-react":"^0.1.3","eslint-plugin-import":"^1.16.0","eslint-plugin-jsx-a11y":"^2.2.3","eslint-plugin-react":"^6.5.0","history":"^4.7.2","karma":"^1.3.0","karma-chrome-launcher":"^2.0.0","karma-firefox-launcher":"^1.0.0","karma-mocha":"^1.2.0","karma-mocha-reporter":"^2.2.0","karma-rollup-preprocessor":"^5.0.1","karma-sinon-chai":"^1.3.2","karma-sourcemap-loader":"^0.3.7","mocha":"^4.0.1","react":"^16.0.0","react-dom":"^16.0.0","react-router-dom":"^4.0","rollup":"^0.50.0","rollup-plugin-babel":"^3.0.2","rollup-plugin-commonjs":"^8.2.4","rollup-plugin-node-resolve":"^3.0.0","rollup-plugin-replace":"^2.0.0","sinon":"^4.0.1","sinon-chai":"^2.14.0"},"gitHead":"0cf80b8e4e435aa64a67c6386e624a164304d10a","_id":"react-router-scroll-4@1.0.0-beta.2","_npmVersion":"6.1.0","_nodeVersion":"8.11.3","_npmUser":{"name":"alivemary","email":"alivemary@gmail.com"},"dist":{"integrity":"sha512-K67Dnm75naSBs/WYc2CDNxqU+eE8iA3I0wSCArgGSHb0xR/7AUcgUEXtCxrQYVTogXvjVK60gmwYvOyRQ6fuBA==","shasum":"d887063ec0f66124aaf450158dd158ff7d3dc279","tarball":"https://registry.npmjs.org/react-router-scroll-4/-/react-router-scroll-4-1.0.0-beta.2.tgz","fileCount":6,"unpackedSize":30370,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbYXzLCRA9TVsSAnZWagAA39YP/3z4b92nl3qUkVHrWJ3N\nWrcZBk+RZn3Jg/z2SEDTcpTq/eYDaX/zzY9+CDjWmCNwIVVaLcPDJ0G8606k\nRcDAbXBE7CAJZGKbS89U61nfIo/hBI9s3Oso5V25L/wotSuyyYwQO2ih4CAO\nRb+QzG2GoOXXgZLsn6bHjljS4/nA62Fzz8tuy2k9O8BMOtl1s85+ySGAmEkW\nT8GZp24LcuofHv+WZHXuk/zARjdngfPxxyGWezZ/0kKE17Sm+eOliWLeiud9\ny6OVr9u/7XDTR9E70AKi4bbLnjmtVYYDxbeiCjzxjRDkLI8cIh010eFc8jeY\nUlFvuMO/KuHH+jQbfQUjie9/XbMnuCKghH3/3EeDeCQaeeudBc140mLhVd9O\nVq+CK8T6HkGNU9M2Eb+Cj4HSkbEdIt5nJr/zMWWK21uEDFsypyFdRBrypod5\n6SUyNDl2BhV2za7iy62bbeyAcR1TKhBEwE4XkOu1yjt6qS0tjnz9jzp3EdxN\nj06SqqrH8fv8sEi9f6HemN5i8UCbpAInx95BVnDkGcfsG3lUYVWfo1zxSBxG\njkLbqYRw3KUE3jWHhFFHMxWsZy0F/RpapIyAiLO5vbwLaeMhQ8RhHMJgmB0C\nFGft0NQNtOF4D3rGEClRTerP+arykO9nkiVMuvzy650/jspO8YzZpem6Cl6t\nFEWk\r\n=8eU5\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEr6OokZ2Gt5iorc5vIWdBAaO36CSDlqOo1FL3lBvSPWAiEA4T52zTzp9KuvcGWKpE9BhK4WAeaTtROLewmfM5Z4Ki4="}]},"maintainers":[{"email":"alivemary@gmail.com","name":"alivemary"},{"email":"gourlaouen.mikael@gmail.com","name":"mijamo"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-router-scroll-4_1.0.0-beta.2_1533115595138_0.24197629268658072"},"_hasShrinkwrap":false}},"readme":"# react-router-scroll for React-router-dom v4\n\n[React Router](https://github.com/reactjs/react-router) scroll management.\n\nreact-router-scroll is a React Router component that adds scroll management using [scroll-behavior](https://github.com/taion/scroll-behavior). By default, the component adds browser-style scroll behavior, but you can customize it to scroll however you want on route transitions.\n\nThis is a fork of the original React Router scroll made to support Reat Router v4. Currently all the original features should be working but it is still in early development, tests have not been completely updated yet and there are probably bugs to be encountered. Do not hesitate to signal them, or fix them through pull requests.\n\n## Usage\n\n```js\nimport { BrowserRouter } from 'react-router-dom';\nimport { ScrollContext } from 'react-router-scroll-4';\n\n/* ... */\n\nReactDOM.render(\n  <BrowserRouter>\n    <ScrollContext>\n      <MyApp />\n    </ ScrollContext>\n  </ BrowserRouter>,\n  container\n);\n```\n\n## Guide\n\n### Installation\n\n```shell\n$ yarn add react-router-scroll-4\n```\n\n### Basic usage\n\nUse the `ScrollContext` wrapper as in the example above. `ScrollContext` Should always have only one child, same as all the `Router` components.\n\nYou can override [scroll-behavior] by sending custom costructor through the property `scrollBehavior` to `ScrollContext`:\n\n```js\n<ScrollContext scrollBehavior={newScrollBehavior}>\n  <MyApp />\n</ ScrollContext>\n```\n\n### Custom scroll behavior\n\nYou can provide a custom `shouldUpdateScroll` as a property of `ScrollContext`. This function is called with the previous and the current router props. Those properties correspond to those accessible through [withRouter](https://reacttraining.com/react-router/web/api/withRouter).\n\nThe function can return:\n\n- a falsy value to suppress updating the scroll position\n- a position array of `x` and `y`, such as `[0, 100]`, to scroll to that position\n- a truthy value to emulate the browser default scroll behavior\n\n```js\nshouldUpdateScroll = (prevRouterProps, { location, history }) => (\n  prevRouterProps && location.pathname !== prevRouterProps.location.pathname\n);\n\nshouldUpdateScroll = (prevRouterProps, { location, history }) => {\n  if (history.action === 'POP') {\n    return false;\n  }\n\n  if (location.state[\"MY-USER-KEY\"] === \"NoScroll\") {\n    return [0, 0];\n  }\n\n  return true;\n};\n```\n\n### Scrolling elements other than `window`\n\nUse `<ScrollContainer>` in components rendered by a `ScrollContext` to manage the scroll behavior of elements other than `window`. Each `<ScrollContainer>` must be given a unique `scrollKey`, and can be given an optional `shouldUpdateScroll` callback that behaves as above. `ScrollContainer` should have exactly one child, which will be the node managed.\n\n```js\nimport { ScrollContainer } from 'react-router-scroll';\n\nfunction Page() {\n  /* ... */\n\n  return (\n    <ScrollContainer\n      scrollKey={scrollKey}\n      shouldUpdateScroll={shouldUpdateScroll}\n    >\n      <MyScrollableComponent />\n    </ScrollContainer>\n  );\n}\n```\n\n`<ScrollContainer>` does not support on-the-fly changes to `scrollKey` or to the DOM node for its child.\n\n### Notes\n\n#### Server side rendering\n\nBoth `<ScrollContainer>`  and `<ScrollContext>` are fine to use in server side rendering context. They just renturn their child without changing them in any way.\n","maintainers":[{"email":"alivemary@gmail.com","name":"alivemary"},{"email":"gourlaouen.mikael@gmail.com","name":"mijamo"}],"time":{"modified":"2022-06-26T08:00:42.553Z","created":"2017-10-24T13:20:06.035Z","1.0.0-beta.1":"2017-10-24T13:20:06.035Z","1.0.0-beta.2":"2018-08-01T09:26:35.224Z"},"homepage":"https://github.com/ytase/react-router-scroll#readme","keywords":["react","react router","scroll"],"repository":{"type":"git","url":"git+https://github.com/ytase/react-router-scroll.git"},"author":{"name":"Jimmy Jia"},"bugs":{"url":"https://github.com/ytase/react-router-scroll/issues"},"license":"MIT","readmeFilename":"README.md","users":{"jay.":true}}