{"name":"framesync","version":"3.1.9","description":"A Unity-inspired render loop for JavaScript","main":"lib/index.js","types":"lib/index.d.ts","module":"dist/framesync.es.js","jsnext:main":"dist/framesync.es.js","scripts":{"build":"rollup -c","watch":"rollup -c -w","lint":"tslint -c tslint.json 'src/**/*.{ts}'","test":"jest","measure":"gzip -c dist/framesync.min.js | wc -c","prepublishOnly":"npm run lint && npm run build"},"files":["lib","dist"],"repository":{"type":"git","url":"git+https://github.com/Popmotion/framesync.git"},"keywords":["animation","raf"],"author":{"name":"Matt Perry"},"license":"MIT","bugs":{"url":"https://github.com/Popmotion/framesync/issues"},"homepage":"https://github.com/Popmotion/framesync#readme","devDependencies":{"jest":"^20.0.4","rollup-plugin-typescript2":"^0.14.0","rollup-plugin-uglify":"^3.0.0","ts-jest":"^20.0.10","typescript":"^2.4.2"},"jest":{"moduleFileExtensions":["ts","tsx","js"],"transform":{".(ts|tsx)$":"<rootDir>/node_modules/ts-jest/preprocessor.js"},"testRegex":"/_tests/.*\\.(ts|tsx|js)$"},"unpkg":"./dist/framesync.min.js","prettier":{"parser":"typescript","singleQuote":true},"gitHead":"c3c066d26660ba2fa885a7bbb49915393a8648fc","_id":"framesync@3.1.9","_npmVersion":"5.6.0","_nodeVersion":"6.9.1","_npmUser":{"name":"popmotion","email":"mattgperry@gmail.com"},"dist":{"integrity":"sha512-avNik/k8Wy0r+A2LkoS+4mBb9PoamhBni2u64gRgs5kc1YrApshw6vDL0tqWxdqcUOXSSg6gI9oN0l0GN/FFjA==","shasum":"f65f815c711cf876f343b1f63da6e18b1384172f","tarball":"http://registry-npm.ywwl.com/framesync/download/framesync-3.1.9.tgz","fileCount":11,"unpackedSize":20848,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa/C/pCRA9TVsSAnZWagAAmZYP/jpDqf3LHIKG1HRS6yji\n8BIRS4UFa9k6R+J2AHnxThj+WoWgBN+vNJ8M4t7wOEMldj9snMnKi/g3J1Gk\nVmNFgeclyye4mEnkKDzBgGrOBySiVYGtPjWXwsU8SVdbD+oIWLexTV0m413S\n3NaALQioon9qn44CZKfmdhiB7B+Rcim11UZ+mpfYWdkOgtDDVSB484O1QRse\nxkyEKhgTCRoLjCDP2JvJj2zfKwfCDRldlmvBFUC20DNNsGczBY796lvyrYf7\njBn+mKj90np8VBatq+i0XBwZgn6MBl6mqesTw3tm48u1O3J61rhXEdLATpN0\nqZnggx12m/f1cg7Qs18/lP1gSm6FJ54ksCBFfl/6Svohx1i8pkfx1YLwC9yL\nmTBF0XkNoLQAvL9X2xGPdX+uzxDUwMLL7tZdZL+NpcbDSfPXoY3AXkVWL22A\n64ABPqIlWio+pqKf2DTR2tykcTVbI6dOKAvXd5m+nV/X/CjIqIPzN414hD9+\n5WAWGaVLQ0yK/kU7Lbo5OP/z1BdV9HGwX7e9hZScoUcMSX1Z7nXg7NfVd0hA\nmc2l3VMgbsR8vJNOfuAkRoO8qJop+jmYC2qXX3omwncpbZqFzK4JjtKZl77O\nzRT+/XBeHYyXjXmiko1v2m6FdWTiG/A7BYgQUsfmEmFUHbDkXgaxbv09TEoW\neTAs\r\n=11O4\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIE4HfXKXRHI8oCa1eNv9rhWnTOXcnwhaBuT8FZLry0BNAiEAnhJFSc6jl5rAZn3I5xjLwX9W4tbYEyjOjxE5PSoZIiE="}],"size":5317,"noattachment":false,"key":"/framesync/-/framesync-3.1.9.tgz"},"maintainers":[{"name":"popmotion","email":"sirhound@popmotion.io"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/framesync_3.1.9_1526476777257_0.23448825217716696"},"_hasShrinkwrap":false,"readme":"# Framesync\n\nA tiny frame scheduler for performantly batching reads, updates and renders.\n\nSegregating actions that read and write to the DOM will avoid [layout thrashing](https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing).\n\nIt's also a way of ensuring order of execution across a frame. For instance, [Framer Motion](https://github.com/framer/motion) batches animations on the `update` step, and renders on the `render` step, allowing independent animation of `transform` properties.\n\n## Install\n\n```bash\nnpm install framesync\n```\n\n## Usage\n\nFramesync splits a frame into discrete `read`, `update`, `preRender`, `render` and `postRender` steps.\n\n### Scheduling functions\n\nFunctions can be scheduled to different parts of the render loop with `sync`.\n\n```javascript\nimport sync from 'framesync';\n```\n\nIt provides four functions, one for scheduling a function to run on each part of the frame:\n\n```javascript\nsync.update(() => {});\n```\n\n### Frame data\n\nEach function is provided data about the current frame:\n\n```javascript\nsync.update(({ delta, timestamp }) => {});\n```\n\n- `delta`: Time since last frame (in milliseconds)\n- `timestamp`: Timestamp of the current frame.\n\nThis object is recycled across frames, so values should be destructured if intended to be used asynchronously.\n\n### Keep alive\n\nWe can run a function as an ongoing process by passing `true` as the second parameter:\n\n```javascript\nlet count = 0;\n\nsync.update(() => count++, true);\n```\n\nThis will keep the process running until it's actively cancelled.\n\n### Run immediately\n\nThe third parameter, `immediate`, can be used to sync a function on the **current frame step**.\n\nBy default, Framesync will schedule functions to run the next time that frame step is fired:\n\n```javascript\nsync.update(({ timestamp }) => {\n  // The following function will run on the subsequent frame:\n  sync.update((frame) => frame.timestamp !== timestamp);\n});\n```\n\nBy setting `immediate` to `true`, we can add this at the end of the current step:\n\n```javascript\nsync.update(({ timestamp }) => {\n  // The following function will run on the **current** frame:\n  sync.update(\n    (frame) => frame.timestamp === timestamp,\n    false,\n    true\n  );\n});\n```\n\n### Cancelling\n\nSynced processes can be cancelled with the `cancelSync` function:\n\n```javascript\nimport sync, { cancelSync } from 'framesync';\n\nlet count = 0;\n\nconst process = sync.render(() => {\n  count++;\n  if (count >= 10) cancelSync.render(process);\n}, true);\n```\n","publish_time":1526476777329,"_cnpm_publish_time":1526476777329,"dist-tags":{"latest":"6.1.2","rc":"6.0.0-rc.1"}}