{"name":"@react-spring/rafz","version":"0.0.0-nightly-bc3ce76-20230405001601","keywords":["animated","animation","hooks","motion","react","react-native","spring","typescript","velocity"],"author":{"name":"Josh Ellis"},"license":"MIT","_id":"@react-spring/rafz@0.0.0-nightly-bc3ce76-20230405001601","homepage":"https://github.com/pmndrs/react-spring/tree/main/packages/rafz#readme","bugs":{"url":"https://github.com/pmndrs/react-spring/issues"},"dist":{"shasum":"03bfc834fcb85d6cb490da0a0bfba6e8e92d3c4f","tarball":"http://registry-npm.ywwl.com/@react-spring/rafz/download/@react-spring/rafz-0.0.0-nightly-bc3ce76-20230405001601.tgz","fileCount":6,"integrity":"sha512-Lvy23elilUpzBj02Vr0Es4ybtmgtK05bqNPM5RPKiEW5N6kS1IIJ1AT50elaVDL+mio3CkcfVHj0rV7bsLyLBQ==","signatures":[{"sig":"MEUCIFEfsgQdCMOEhczXmd/5plfbfZfa1Vk2Q2qdtFjVCN9NAiEA8QuarnoUzebv3R9wEmlRMUDRqIksOzliiXJvKq8IvX8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11706,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkLL3MACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrPGA/+KASBq/3mYkhYID5+DH1vQj+0wiCNR/mKW8v1v5NCSsGY7iG5\r\nCcacBMZl4ucXFRljWFeFvj2VX5lrCF66AYd6TpaDKXed6/1utfCQMtmlsvgE\r\nl6YvfztXlBmyX+d6t4VtfsulP/gNEyRUXUBUlIkG5iBtAob4VXIIq6NKk1hl\r\nT6/zfT3gu8dQDePvOi1tXfyVLnxThNRvxqoT8p+P2x0FrTsrVa4byxYtcC4D\r\n6Y2bS2phgR5frxYNh9D3NijnNTj0t62yBzB3rUE3jJtm14QZ2+LVSWACP6U/\r\ng8tczdLG4UwlsLOexfeg6qFyzP6zQH1IowvskAWl9fZ5Oi7nY9IjPm00tgJl\r\nCoxvzM86g9bEiiN0vJf8kOqpHxDbErqyKdhcYGOI94d8uQfORlL5iQqrxP1n\r\nqtoCB7o8zHJ43jwYoCXoUm+Vjm4HEpkUvNbKyaPbyrTSB4dQ2qhZouC8TaWe\r\n/TPj9aT6V75xSGXgsP+wPatQWBlvgu2KZJlyb+zp4MSNrAxHQqHeo2L13b22\r\n7zrUvij3iHe0B8shcbaFpKPr5ecTr9h9EFOQp0ypTrUowR4qa896hvSBYRMl\r\nBE1H0CiISDC7mU6npQJcG/oqz48P5B0jYzCE8Ne8Q70kmp6LQoGtxhpcSG3u\r\nz0yGZPKL4Gvn3GD85vunbNWJXI+WO6MP6SU=\r\n=e5ey\r\n-----END PGP SIGNATURE-----\r\n","size":4885,"noattachment":false,"key":"/@react-spring/rafz/-/@react-spring/rafz-0.0.0-nightly-bc3ce76-20230405001601.tgz"},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/esm/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/esm/index.js","module":"./dist/esm/index.js","require":"./dist/index.js"},"./package.json":"./package.json"},"gitHead":"bc3ce7604e608fee8b04feddf0011035433431f6","scripts":{"dev":"tsup","lint":"TIMING=1 eslint \"src/**/*.ts*\"","build":"tsup --legacy-output","clean":"rm -rf .turbo && rm -rf node_modules && rm -rf dist"},"_npmUser":{"name":"tdfka_rick","email":"Joshua.ellis18@gmail.com"},"repository":{"url":"git+https://github.com/pmndrs/react-spring.git","type":"git"},"_npmVersion":"9.5.0","description":"react-spring's fork of rafz one frameloop to rule them all","directories":{},"_nodeVersion":"18.15.0","_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/rafz_0.0.0-nightly-bc3ce76-20230405001601_1680653772453_0.5684297131718425","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":1680653772685,"maintainers":[{"name":"tdfka_rick","email":"Joshua.ellis18@gmail.com"}],"_cnpm_publish_time":1680653772685,"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"}}