Package Exports
- framesync
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (framesync) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Framesync
A tiny frame scheduler for performantly batching reads and renders. Segregating actions that read and write to the DOM will avoid layout thrashing.
Install
npm install framesync --saveUsage
The Framesync render loop executes four sequential steps, once per frame.
frameStartframeUpdateframeRenderframeEnd
Developers can set any function to run at any of these steps using the on and cancel callbacks:
onFrameStart,cancelOnFrameStartonFrameUpdate,cancelOnFrameUpdateonFrameRender,cancelOnFrameRenderonFrameEnd,cancelOnFrameEnd
Framesync also exports some time-measurement methods:
currentTime: The current time as measured by the host platform's most accuratenowfunction.currentFrameTime: The time the currentrequestAnimationFramewas initiated.timeSinceLastFrame: The duration between the previous frame and the currentcurrentFrameTime
Example
import {
timeSinceLastFrame,
onFrameStart,
cancelFrameStart
} from 'popmotion';
function logTimeSinceLastFrame() {
console.log(timeSinceLastFrame());
onFrameStart(logTimeSinceLastFrame);
}
onFrameStart(logTimeSinceLastFrame);
function stopLogging() {
cancelOnFrameStart(logTimeSinceLastFrame);
}
setTimeout(stopLogging, 5000);