{"name":"@react-spring/rafz","version":"9.6.0","keywords":["animated","animation","hooks","motion","react","react-native","spring","typescript","velocity"],"author":{"name":"Josh Ellis"},"license":"MIT","_id":"@react-spring/rafz@9.6.0","homepage":"https://github.com/pmndrs/react-spring/tree/master/packages/rafz#readme","bugs":{"url":"https://github.com/pmndrs/react-spring/issues"},"dist":{"shasum":"8c46fff30157159775eb9007094dae3400390728","tarball":"http://registry-npm.ywwl.com/@react-spring/rafz/download/@react-spring/rafz-9.6.0.tgz","fileCount":10,"integrity":"sha512-Vw8IwWXWEMszef8V/yemSR8YZe4cbX84JrMMuW+UE5Ha1/mOCznlFU59fKJxQQA/UJlfY70K9oZ+aboFgWWk0g==","signatures":[{"sig":"MEUCIDI8zKxV2H0DqsOy0UEP7ZIPymX1ZkeliZtn5ij/ILnqAiEAobAw6ZEkL2qmm1JDxW4ZFlJ7uFu5svOA/5A4qtd0jfA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":19576,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjlu01ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmof3w//SFxJz04lozDMZPatbyOZbiYThmqWjCc0pshVe/+uYft3rqA8\r\nXS9rZ++VIryMvfXKS/GCkAWYfspdE4X+c4lLWzIZVdS1D0+MAkHx6YhWxZdV\r\ngigcTVaXzA6czzIz1nbz+UHoLAV3g4nmw/l9l7mo88A7RaF6tk55gEZPwg/m\r\nrMKDwMH57+UmLmf7SaxdrZ785vqeTLBN7l0K8wFcf85aX6DxPkJyW5gw4zMB\r\nduA8rzPDmIsjh/DBLcs21CNm1xiUiPBzCFFJ7P6zl6I0M73NyTr+RjX4nveo\r\nJCPXoqXZkXY8NrW3sq3bty2CcSeguhCEALH8o0lOIfTt6e6lA1z7do3VQ7E0\r\n3pTu5gbTTM5bQOaICKXPwYVGmY1pyWnUkstpnB7OkqqtLdvsCPw+ABpn2IbF\r\ngtaZ/dsqBpBmkXwpy67xURO3W3syOiSWVVA49tausw0ZVqMcwvgE3Ku4BZ/m\r\nV5hy7PZzRRcr0pC/wjBlvh//iBhl53dA0ApBfdtoo74EfIohZS2WYJgmpxtX\r\nQ5mzlwBNv8xKQ52GIhFqabQyRj9XVIrxAGd3GcukRxUnPnpQzBbtlLjqakRl\r\ncIJ8aGud/5l9u9qFaFqDam2PcsPNj1zKlodNV2kvGO5b7wJjl80sW2hBImsH\r\nNXx396PVNPxyY1vrD0+xkAEGC0M8JcoR5gA=\r\n=pn4Q\r\n-----END PGP SIGNATURE-----\r\n","size":4851,"noattachment":false,"key":"/@react-spring/rafz/-/@react-spring/rafz-9.6.0.tgz"},"main":"dist/react-spring-rafz.cjs.js","types":"./dist/react-spring-rafz.cjs.d.ts","module":"dist/react-spring-rafz.esm.js","gitHead":"2735c463f70f4df62ec4a4350f691ce5e1f8ed4f","_npmUser":{"name":"tdfka_rick","email":"Joshua.ellis18@gmail.com"},"repository":{"url":"git+https://github.com/pmndrs/react-spring.git","type":"git"},"_npmVersion":"8.15.0","description":"react-spring's fork of rafz one frameloop to rule them all","directories":{},"_nodeVersion":"18.7.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/rafz_9.6.0_1670835509789_0.8127643356810321","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":1670835509964,"maintainers":[{"name":"tdfka_rick","email":"Joshua.ellis18@gmail.com"}],"_cnpm_publish_time":1670835509964,"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"}}