{"name":"@react-spring/rafz","version":"10.1.2","description":"react-spring's fork of rafz one frameloop to rule them all","module":"./dist/react-spring_rafz.legacy-esm.js","main":"./dist/cjs/index.js","types":"./dist/react-spring_rafz.modern.d.mts","exports":{"./package.json":"./package.json",".":{"import":{"types":"./dist/react-spring_rafz.modern.d.mts","default":"./dist/react-spring_rafz.modern.mjs"},"require":{"types":"./dist/cjs/react-spring_rafz.development.d.ts","default":"./dist/cjs/index.js"}}},"repository":{"type":"git","url":"git+https://github.com/pmndrs/react-spring.git"},"homepage":"https://github.com/pmndrs/react-spring/tree/main/packages/rafz#readme","keywords":["animated","animation","hooks","motion","react","react-native","spring","typescript","velocity"],"license":"MIT","author":{"name":"Josh Ellis"},"publishConfig":{"provenance":true},"scripts":{"build":"rm -rf dist && tsdown","clean":"rm -rf .turbo && rm -rf node_modules && rm -rf dist","dev":"tsdown --watch","pack":"pnpm pack && mv *.tgz package.tgz"},"_id":"@react-spring/rafz@10.1.2","bugs":{"url":"https://github.com/pmndrs/react-spring/issues"},"_integrity":"sha512-KC6vSFZyPnRJ2rXqipV9QqR4SaYbYXjvKfdYKWipNK2mWuV79gr20WmpVUOsTiEHGRY3WSOdWCHN+P9Pdaqb7Q==","_resolved":"/tmp/edfe6de3633cadbf398aa32ea9d3dbde/react-spring-rafz-10.1.2.tgz","_from":"file:react-spring-rafz-10.1.2.tgz","_nodeVersion":"24.16.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-KC6vSFZyPnRJ2rXqipV9QqR4SaYbYXjvKfdYKWipNK2mWuV79gr20WmpVUOsTiEHGRY3WSOdWCHN+P9Pdaqb7Q==","shasum":"980a3050f4346fd238e7e558d16484c7e3b14846","tarball":"http://registry-npm.ywwl.com/@react-spring/rafz/download/@react-spring/rafz-10.1.2.tgz","fileCount":12,"unpackedSize":33436,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@react-spring%2frafz@10.1.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDbHX0kiW1SZawLMW8tT/Xb+GUPZ2OdiTD1C9QCG7IGjAIhAPtntChAkX6wEUA0a4zbloIjdf0brMrOoUXtTGRtr6F7"}],"size":6384,"noattachment":false,"key":"/@react-spring/rafz/-/@react-spring/rafz-10.1.2.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:6745e1b7-9797-478c-b7e5-256216a1c81c"}},"directories":{},"maintainers":[{"name":"tdfka_rick","email":"joshua.ellis18@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/rafz_10.1.2_1782290782635_0.7778916944362377"},"_hasShrinkwrap":false,"readme":"# @react-spring/rafz\n\nCoordinate `requestAnimationFrame` calls across your app and/or libraries.\n\n- < 700 bytes min+gzip\n- Timeout support\n- Batching support (eg: `ReactDOM.unstable_batchedUpdates`)\n- Uncaught errors are isolated\n- Runs continuously (to reduce frame skips)\n\n&nbsp;\n\n## API\n\n```ts\nimport { raf } from '@react-spring/rafz'\n\n// Schedule an update\nraf(dt => {})\n\n// Start an update loop\nraf(dt => true)\n\n// Cancel an update\nraf.cancel(fn)\n\n// Schedule a mutation\nraf.write(() => {})\n\n// Before any updates\nraf.onStart(() => {})\n\n// Before any mutations\nraf.onFrame(() => {})\n\n// After any mutations\nraf.onFinish(() => {})\n\n// Set a timeout that runs on nearest frame\nraf.setTimeout(() => {}, 1000)\n\n// Use a polyfill\nraf.use(require('@essentials/raf').raf)\n\n// Get the current time\nraf.now() // => number\n\n// Set how you want to control raf firing\nraf.frameLoop = 'demand' | 'always'\n```\n\n&nbsp;\n\n## Notes\n\n- Functions can only be scheduled once per queue per frame.\n- Thus, trying to schedule a function twice is a no-op.\n- The `update` phase is for updating JS state (eg: advancing an animation).\n- The `write` phase is for updating native state (eg: mutating the DOM).\n- [Reading] is allowed any time before the `write` phase.\n- Writing is allowed any time after the `onFrame` phase.\n- Timeout handlers run first on each frame.\n- Any handler (except timeouts) can return `true` to run again next frame.\n- The `raf.cancel` function only works with `raf` handlers.\n- Use `raf.sync` to disable scheduling in its callback.\n- Override `raf.batchedUpdates` to avoid excessive re-rendering in React.\n\n[reading]: https://gist.github.com/paulirish/5d52fb081b3570c81e3a\n\n&nbsp;\n\n## `raf.throttle`\n\nWrap a function to limit its execution to once per frame. If called more than once\nin a single frame, the last arguments are used.\n\n```ts\nlet log = raf.throttle(console.log)\n\nlog(1)\nlog(2) // nothing logged yet\n\nraf.onStart(() => {\n  // \"2\" is logged by now\n})\n\n// Cancel a pending call.\nlog.cancel()\n\n// Access the wrapped function.\nlog.handler\n```\n\n## Prior art\n\n- [fastdom](https://github.com/wilsonpage/fastdom)\n- [framesync](https://github.com/Popmotion/popmotion/tree/master/packages/framesync)\n","publish_time":1782290782800,"_cnpm_publish_time":1782290782800,"dist-tags":{"alpha":"9.4.0-alpha.0","beta":"11.0.0-beta.1","experimental":"0.0.0-65fc02cc281573bc28d90720983c8e9df9035059-20230625170003","latest":"10.1.2","nightly":"0.0.0-nightly-52cc710-20230626001840"}}