{"name":"@react-spring/rafz","version":"0.0.0-aefd1e584376be38b1f6ca1ca74e061c4ce9b9d8-20230225174818","keywords":["animated","animation","hooks","motion","react","react-native","spring","typescript","velocity"],"author":{"name":"Josh Ellis"},"license":"MIT","_id":"@react-spring/rafz@0.0.0-aefd1e584376be38b1f6ca1ca74e061c4ce9b9d8-20230225174818","homepage":"https://github.com/pmndrs/react-spring/tree/master/packages/rafz#readme","bugs":{"url":"https://github.com/pmndrs/react-spring/issues"},"dist":{"shasum":"b955a50c116c14559c8a1907ebc232c444717379","tarball":"http://registry-npm.ywwl.com/@react-spring/rafz/download/@react-spring/rafz-0.0.0-aefd1e584376be38b1f6ca1ca74e061c4ce9b9d8-20230225174818.tgz","fileCount":3,"integrity":"sha512-FfzEDx7o5HwpAns6kpHKcsr6Uz0XK2NgHKWdJxh6EnWvR5JNXFt7RGJ3g9HXhvlro13r25zfovF6f0bu8vO0Sw==","signatures":[{"sig":"MEQCIFpJjy8+VssZGoLdfk8LyV8+u2MLMw81bOaMFfnCKbgNAiA4NRDp731Atj7DCO50LXyXl+FnqKD0ZIY4fFfm5UA3fg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4235,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj+knrACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmroSQ/7BN45IqAvTiZJ989Uj8crcgCXg9Ajc2UQEy4BYxIXdcn6yWjA\r\n29CwKIbovX1mPkn22HRXfnJ9+w7M/zGwF6ybyr4xdzs/IokZhRGxJFGh8Txx\r\nbcI9j4/bvr1b78ax2TKZlwCTZLN7AyLDJg6sqXsci7Xxl6i/y2oK45Qt4l58\r\nXYNjjGRNxj/hhU8P5mB9WDhurRwZmCjXcNOY/N3XigxaVnsSm09bHFObOzkR\r\nQINmdQKEA32QhLqbxTB+CifTNrGO7HPLG4uIwwZh+2q2iekDxVtEhyQJbbCL\r\nDkcKk1Aiem5CFHYq/PMIbYMzyzgQCcWLhjbH91eVBhSqOLpJBIh/9OkwHpgP\r\nRsTweLE6JgW1jmdU56vGlV4Hx5bLauwi5rB7Mp0bDIrlxkdnZbnvoyh54m5u\r\nlOqE6SFVGFc+33U6J132UhlSjWe9Y8v2sBSt3b8g5Khp9nBMufSoV+H+3KCO\r\nI+1GSe94SLFisu4RWR1sAoW+dJW2pjcm1LmBbgoolHs2l7ANNkJzqVU9sgoT\r\niBxtsTOr6EEKPGqa1KiFziSebmKu2msD08fp3muyxuD6xrE7wFNY5KfjRNp7\r\nIWMauigQhfrmjaWRmZ+dKk9Q5iIJ3mfJLvQijnJPRURRmokfWV8GNZ7kZjvS\r\n+eeSq5esbVdU4hgxgyCJhIcZ8IYETUTomlY=\r\n=YxEd\r\n-----END PGP SIGNATURE-----\r\n","size":2271,"noattachment":false,"key":"/@react-spring/rafz/-/@react-spring/rafz-0.0.0-aefd1e584376be38b1f6ca1ca74e061c4ce9b9d8-20230225174818.tgz"},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./package.json":"./package.json"},"gitHead":"aefd1e584376be38b1f6ca1ca74e061c4ce9b9d8","scripts":{"dev":"tsup","build":"tsup"},"_npmUser":{"name":"tdfka_rick","email":"Joshua.ellis18@gmail.com"},"repository":{"url":"git+https://github.com/pmndrs/react-spring.git","type":"git"},"_npmVersion":"9.3.1","description":"react-spring's fork of rafz one frameloop to rule them all","directories":{},"_nodeVersion":"18.14.1","_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/rafz_0.0.0-aefd1e584376be38b1f6ca1ca74e061c4ce9b9d8-20230225174818_1677347307525_0.6834633058755417","host":"s3://npm-registry-packages"},"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":1677347307693,"maintainers":[{"name":"tdfka_rick","email":"Joshua.ellis18@gmail.com"}],"_cnpm_publish_time":1677347307693,"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"}}