Comparing version 1.0.1 to 2.0.0
{ | ||
"name": "framesync", | ||
"version": "1.0.1", | ||
"description": "A high-performance, frame-synced render loop for any JavaScript environment.", | ||
"author": "Matt Perry <sirhound@popmotion.io>", | ||
"homepage": "http://popmotion.io", | ||
"main": "./lib/framesync.js", | ||
"version": "2.0.0", | ||
"description": "A tiny frame scheduler for performantly batching reads and renders", | ||
"main": "lib/index.js", | ||
"types": "src/index.d.ts", | ||
"files": [ | ||
"lib", | ||
"framesync.global.js", | ||
"framesync.global.min.js" | ||
"src/index.d.ts" | ||
], | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"prepublishOnly": "tsc" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Popmotion/framesync" | ||
"url": "git+https://github.com/Popmotion/framesync.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/Popmotion/framesync/issues" | ||
}, | ||
"keywords": [ | ||
"requestAnimationFrame", | ||
"animation" | ||
"popmotion", | ||
"animation", | ||
"raf" | ||
], | ||
"analyze": true, | ||
"author": "Matt Perry", | ||
"license": "MIT", | ||
"scripts": { | ||
"compile": "babel src --out-dir lib && NODE_ENV=production webpack", | ||
"watch": "NODE_ENV=development webpack --progress --colors --watch", | ||
"measure": "gzip -c framesync.global.min.js | wc -c", | ||
"test": "mocha --compilers js:babel-core/register" | ||
"bugs": { | ||
"url": "https://github.com/Popmotion/framesync/issues" | ||
}, | ||
"devDependencies": { | ||
"babel-core": "^6.0.20", | ||
"babel-loader": "^6.0.1", | ||
"babel-preset-es2015-subset-loose": "^1.0.0", | ||
"babel-preset-stage-2": "^6.0.15", | ||
"babel-register": "^6.3.13", | ||
"chai": "^3.4.0", | ||
"jshint": "^2.8.0", | ||
"jshint-loader": "^0.8.3", | ||
"webpack": "1.7.2" | ||
} | ||
"homepage": "https://github.com/Popmotion/framesync#readme" | ||
} |
127
README.md
@@ -1,16 +0,7 @@ | ||
# Framesync | ||
A frame-synced render loop for use in any JavaScript environment. | ||
# framesync | ||
## Features | ||
- Tiny: < 1.5kb minified and gzipped. | ||
- Compatible with all browsers, Node and React Native environments. | ||
- Discrete render steps execute all processes in parallel. | ||
- `willRender` method can prevent unnecessary `render` calls. | ||
- Auto-sleeps when there are no active processes. | ||
- Controllable time dilation - speed up or slow down every Process simultaneously. | ||
A tiny frame scheduler for performantly batching reads and renders. | ||
## Quick start | ||
## Install | ||
### Install | ||
```bash | ||
@@ -20,112 +11,2 @@ npm install framesync --save | ||
### Use | ||
```javascript | ||
import { Process } from 'framesync'; | ||
let frame = 0; | ||
const frameCounter = new Process({ | ||
update: () => frame++, | ||
render: () => console.log(frame) | ||
}); | ||
frameCounter.start(); | ||
``` | ||
## Render loop steps | ||
This is the default order of execution for `Process` steps, once per frame: | ||
![framesync render loop](/assets/renderloop.png) | ||
Framesync will fire the `frameStart` method of all active processes, then all the `update` methods, and so on. | ||
Each step is optional, and each method (if defined) is called with the arguments `process, frameStamp, frameDuration`, in the context of the `Process` itself. | ||
If a Process' `willRender` is defined **and** returns `false`, its render methods will be skipped for that frame. | ||
*** | ||
## API | ||
### `Process` | ||
A `Process` is a collection of methods to be run once per frame, and can be started/stopped at any time. | ||
#### Create | ||
```javascript | ||
import { Process } from 'framesync'; | ||
const process = new Process(steps, isLazy); | ||
``` | ||
#### Arguments | ||
##### `steps` [object] | ||
Object of step functions, each individually optional. | ||
##### `isLazy` [boolean] *(optional)* | ||
If `true`, this `Process` will only fire when non-lazy Processes are also active. | ||
#### Methods | ||
##### `.start()` | ||
Start the process on the next available frame. | ||
##### `.stop()` | ||
Stop the process after the next available frame. | ||
##### `.once()` | ||
Fire the process once on the next available frame. | ||
### `setTimeDilation()` | ||
Control global time dilation and speed up/slow down all active Processes. | ||
```javascript | ||
import { setTimeDilation } from 'framesync'; | ||
setTimeDilation(dilation); | ||
``` | ||
#### Arguments | ||
##### `dilation` [number] | ||
```javascript | ||
setTimeDilation(0.5); // Timer runs at half speed | ||
setTimeDilation(2); // Timer runs at double speed | ||
``` | ||
### `setSteps()` | ||
**Warning:** Changing the step execution order can break dependant modules. Only use if you have full stack control. | ||
```javascript | ||
import { setSteps } from 'framesync'; | ||
setSteps(stepOrder); | ||
``` | ||
#### Arguments | ||
##### `stepOrder` [array] | ||
Array of step definition objects. Steps will be executed in the order of the array. | ||
A step definition must have a `step` property, which is the name of the method to be executed. | ||
Any step can be given a `decideRender` property. Subsequent steps with `isRender` set to `true` will be skipped if its `decideRender` step method returns `false`. | ||
###### Example | ||
```javascript | ||
const stepOrder = [ | ||
{ step: 'start' }, | ||
{ step: 'willRender', decideRender: true }, | ||
{ step: 'preRender', isRender: true }, | ||
{ step: 'end' } | ||
]; | ||
setSteps(stepOrder); | ||
``` | ||
## Usage |
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
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
0
9466
10
98
2
12
1