{"_id":"@kaliber/use-scroll-velocity","_rev":"26-a371e22b7aceb557c08f84aed2441133","name":"@kaliber/use-scroll-velocity","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@kaliber/use-scroll-velocity","version":"1.0.0","keywords":["scroll","react","r3f","react-three-fiber","threejs","velocity"],"license":"MIT","_id":"@kaliber/use-scroll-velocity@1.0.0","maintainers":[{"name":"daveykropf","email":"davey@kaliber.net"},{"name":"eecolor","email":"eecolor@gmail.com"},{"name":"jerryduijm","email":"jduijm@kaliber.net"},{"name":"kaliber-owner","email":"development@kaliber.net"},{"name":"sielcken","email":"hsielcken@kaliber.net"},{"name":"nhoenderop","email":"nhoenderop@kaliber.net"},{"name":"erwin-kaliber","email":"ehaers@kaliber.net"},{"name":"janbru","email":"jbrunemann@kaliber.net"},{"name":"melissabos18","email":"mbos@kaliber.net"},{"name":"albertkaliber","email":"asmit@kaliber.net"},{"name":"frekemeijeraan","email":"fmeijeraan@kaliber.net"},{"name":"hothmani","email":"hothmani@kaliber.net"},{"name":"yoreljenkins","email":"ldavidsondescelles@kaliber.net"}],"dist":{"shasum":"c136e09b9c9cf2e8f86e4a7f19a4d3a374f0407b","tarball":"https://registry.npmjs.org/@kaliber/use-scroll-velocity/-/use-scroll-velocity-1.0.0.tgz","fileCount":7,"integrity":"sha512-ww2gHpGLWoiotzwC6ew6IooKvxautAsis/JnXZuqmt5N2tcLhC+VrU0MaNDLA8vMzwVQA462wLuvLsMEuFkKqA==","signatures":[{"sig":"MEUCIQDdYBOA5X0RK2TAUJIKCx4rhipd8ZQpv0gjerDZW2xHOQIgDL+eTQJsfy971Ni+Q6VRulDMXp41+cjq33q/0DW0FpQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5348},"main":"index.js","private":false,"_npmUser":{"name":"yoreljenkins","email":"ldavidsondescelles@kaliber.net"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.","repository":{"url":"https://github.com/kaliberjs/use-scroll-velocity.git","type":"git"},"description":"A helper library to track the users scroll velocity","directories":{},"licenseText":"MIT License\n\nCopyright (c) 2021 kaliber.js\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","sideEffects":false,"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/use-scroll-velocity_1.0.0_1746603825018_0.4885159272440731","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@kaliber/use-scroll-velocity","version":"1.0.1","keywords":["scroll","react","r3f","react-three-fiber","threejs","velocity"],"license":"MIT","_id":"@kaliber/use-scroll-velocity@1.0.1","maintainers":[{"name":"daveykropf","email":"davey@kaliber.net"},{"name":"eecolor","email":"eecolor@gmail.com"},{"name":"jerryduijm","email":"jduijm@kaliber.net"},{"name":"kaliber-owner","email":"development@kaliber.net"},{"name":"sielcken","email":"hsielcken@kaliber.net"},{"name":"nhoenderop","email":"nhoenderop@kaliber.net"},{"name":"erwin-kaliber","email":"ehaers@kaliber.net"},{"name":"janbru","email":"jbrunemann@kaliber.net"},{"name":"melissabos18","email":"mbos@kaliber.net"},{"name":"albertkaliber","email":"asmit@kaliber.net"},{"name":"frekemeijeraan","email":"fmeijeraan@kaliber.net"},{"name":"hothmani","email":"hothmani@kaliber.net"},{"name":"yoreljenkins","email":"ldavidsondescelles@kaliber.net"}],"dist":{"shasum":"3df9999a20f73753a2e9c5bc7be6f85ec4fd5e2b","tarball":"https://registry.npmjs.org/@kaliber/use-scroll-velocity/-/use-scroll-velocity-1.0.1.tgz","fileCount":7,"integrity":"sha512-wf1ddsvvcpH/ONlAMK9uy3eoL9BPq6hPm+kpEtAArUzTiKZIulem+3QW0qwOCkgTaDGchPYo2o+lw7qWkIZWtg==","signatures":[{"sig":"MEQCIE21jEOGxgNSrJ6puaCyGSmxjlkItRaVlLBcRtWoe8GaAiANjH8FF85LRp4TLXGTSc7oHnwIk4TXvpd2VwUqocBGpA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5081},"main":"index.js","private":false,"_npmUser":{"name":"yoreljenkins","email":"ldavidsondescelles@kaliber.net"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.","repository":{"url":"https://github.com/kaliberjs/use-scroll-velocity.git","type":"git"},"description":"A helper library to track the users scroll velocity","directories":{},"licenseText":"MIT License\n\nCopyright (c) 2021 kaliber.js\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","sideEffects":false,"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/use-scroll-velocity_1.0.1_1746603922632_0.07009119414075293","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2025-05-07T07:43:44.952Z","modified":"2026-09-09T12:43:47.795Z","1.0.0":"2025-05-07T07:43:45.177Z","1.0.1":"2025-05-07T07:45:22.805Z"},"license":"MIT","keywords":["scroll","react","r3f","react-three-fiber","threejs","velocity"],"repository":{"url":"https://github.com/kaliberjs/use-scroll-velocity.git","type":"git"},"description":"A helper library to track the users scroll velocity","maintainers":[{"email":"davey@kaliber.net","name":"daveykropf"},{"email":"ewestra@kaliber.net","name":"eecolor"},{"email":"jduijm@kaliber.net","name":"jerryduijm"},{"email":"development@kaliber.net","name":"kaliber-owner"},{"email":"nhoenderop@kaliber.net","name":"nhoenderop"},{"email":"jbrunemann@kaliber.net","name":"janbru"},{"email":"asmit@kaliber.net","name":"albertkaliber"},{"email":"mvanbrakel@kaliber.net","name":"mvanbrakel"},{"email":"Rvanschaik@kaliber.net","name":"r0h-oh"},{"email":"claan@kaliber.net","name":"1cln"},{"email":"mreimus@kaliber.net","name":"maart-22"},{"email":"ldavidsondescelles@kaliber.net","name":"yoreljenkins"},{"email":"mdevalk@kaliber.net","name":"mdevalk1983"},{"email":"guido.evertzen@gmail.com","name":"guido.evertzen"},{"email":"svroom@kaliber.net","name":"svroom-kaliber"},{"email":"tomharms93@proton.me","name":"tomharms"},{"email":"rinus.vh@hotmail.com","name":"rinus.vh"},{"email":"pgoddijn@gmail.com","name":"pgoddijn"},{"email":"jvankralingen@kaliber.net","name":"jvankralingen"}],"readme":"# useScrollVelocity\nA library that returns an immutable value that signifies the users scroll velocity.\n\nIt returns a positive float on down scroll and a negative float on up scroll behavior.\nThe returned value is lerped, the lerp speed is `0.1` by default but can be overwritten by passing the `lerpSpeed` prop, if you need additional smoothing functionality you should either use your own function or use it in conjunction with ThreeJS Math utils like lerp.\n\nExample with built in lerp:\n```js\nconst scrollVelocity = useScrollVelocity({ lerpSpeed: 0.3 })\n```\n\nExample with ThreeJS Math util:\n```js\nconst meshRef = React.useRef()\nconst lerpSpeed = 0.3\nconst scrollVelocity = useScrollVelocity()\n\nconst THREELerp = THREE.MathUtils.lerp(\n    meshRef.current.material.uniforms.uScrollVelocity.value,\n    scrollVelocity.current,\n    lerpSpeed\n)\n```\n\n## Motivation\nCreating animations that react to the speed of which the user scrolls can be a bit tricky. Most libraries that give this kind of functionality require you to install their entire package. This package tries to solve this by returning an immutable value that serves a singular purpose. \n\n## Installation\n\n```\nyarn add @kaliber/use-scroll-velocity\n```\n\n## Usage\n\n```jsx\nimport { useScrollVelocity } from '@kaliber/use-scroll-velocity'\n\nfunction R3FComponent() {\n    const scrollVelocity = useScrollVelocity()\n    const meshRef = React.useRef()\n\n    useFrame(() => {\n        const normalizedVelocity = scrollVelocity.current * 0.01\n        meshRef.current.rotation.z += normalizedVelocity\n    })\n\n    return <mesh ref={meshRef}><boxMesh /></mesh>\n}\n```\n\n# Reference\nThis library is mainly used as an immutable state reference for ThreeJS / R3F. \n\n![](https://media4.giphy.com/media/v1.Y2lkPTc5MGI3NjExMHhxNjBhaGo5bDJ0bmJoMGVsdmk1MzhvcDBoOHh3M2NxeHhhZzIwNiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/pjOTiMEkFKlN8lQXOT/giphy.gif)\n\n## Disclaimer\nThis library is intended for internal use, we provide __no__ support, use at your own risk. It does not import React, but expects it to be provided, which [@kaliber/build](https://kaliberjs.github.io/build/) can handle for you.\n\nThis library is not transpiled.\n","readmeFilename":"readme.md"}