Comparing version 2.0.0 to 2.0.1
{ | ||
"name": "framesync", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "A tiny frame scheduler for performantly batching reads and renders", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -1,4 +0,4 @@ | ||
# framesync | ||
# Framesync | ||
A tiny frame scheduler for performantly batching reads and renders. | ||
A tiny frame scheduler for performantly batching reads and renders. Segregating 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). | ||
@@ -12,1 +12,40 @@ ## Install | ||
## Usage | ||
The Framesync render loop executes four sequential steps, once per frame. | ||
- `frameStart` | ||
- `frameUpdate` | ||
- `frameRender` | ||
- `frameEnd` | ||
Developers can set any function to run at any of these steps using the `on` and `cancel` callbacks: | ||
- `onFrameStart`, `cancelOnFrameStart` | ||
- `onFrameUpdate`, `cancelOnFrameUpdate` | ||
- `onFrameRender`, `cancelOnFrameRender` | ||
- `onFrameEnd`, `cancelOnFrameEnd` | ||
`timeSinceLastFrame` and `currentFrameTimestamp` methods provide frame-locked time measurements. | ||
### Example | ||
```javascript | ||
import { | ||
timeSinceLastFrame, | ||
onFrameStart, | ||
cancelFrameStart | ||
} from 'popmotion'; | ||
function logTimeSinceLastFrame() { | ||
console.log(timeSinceLastFrame()); | ||
onFrameStart(logTimeSinceLastFrame); | ||
} | ||
onFrameStart(logTimeSinceLastFrame); | ||
function stopLogging() { | ||
cancelOnFrameStart(logTimeSinceLastFrame); | ||
} | ||
setTimeout(stopLogging, 5000); | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
10720
11
51
0