implement pinch to zoom
This commit is contained in:
+2
@@ -0,0 +1,2 @@
|
||||
components
|
||||
build
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
|
||||
1.2.0 / 2014-09-14
|
||||
==================
|
||||
|
||||
* remove never implemented -o and -ms prefixes (@darsain)
|
||||
|
||||
1.1.3 / 2014-02-11
|
||||
==================
|
||||
|
||||
* package: rename to "component-raf"
|
||||
* package: add "main" field
|
||||
|
||||
1.1.2 / 2013-07-12
|
||||
==================
|
||||
|
||||
* fix .cancel() with fallback #4 @ilsken
|
||||
|
||||
1.1.1 / 2013-07-12
|
||||
==================
|
||||
|
||||
* fix .cancel(), bitches when window is not the receiver...
|
||||
|
||||
1.1.0 / 2013-07-12
|
||||
==================
|
||||
|
||||
* add .cancel(id)
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
|
||||
build: components index.js
|
||||
@component build --dev
|
||||
|
||||
components:
|
||||
@component install --dev
|
||||
|
||||
clean:
|
||||
rm -fr build components template.js
|
||||
|
||||
.PHONY: clean
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
|
||||
# raf
|
||||
|
||||
request animation frame
|
||||
|
||||
## Installation
|
||||
|
||||
$ component install component/raf
|
||||
|
||||
## Example
|
||||
|
||||
Request the animation frame with `raf(fn)`, cancel with `raf.cancel(id)`.
|
||||
|
||||
```js
|
||||
var x = 0;
|
||||
var y = 50;
|
||||
var canvas = document.querySelector('canvas');
|
||||
var ctx = canvas.getContext('2d');
|
||||
var raf = require('raf');
|
||||
|
||||
function animate() {
|
||||
raf(animate);
|
||||
draw();
|
||||
}
|
||||
|
||||
var prev = Date.now();
|
||||
function draw() {
|
||||
var curr = Date.now();
|
||||
var diff = curr - prev;
|
||||
var p = diff / 16;
|
||||
ctx.clearRect(0, 0, 900, 300);
|
||||
ctx.beginPath();
|
||||
ctx.globalAlpha = .5;
|
||||
ctx.arc(x, y, 10, 0, Math.PI * 2, false);
|
||||
ctx.fill();
|
||||
x += 2;
|
||||
y += Math.sin(x/20) * 5;
|
||||
prev = curr;
|
||||
}
|
||||
|
||||
animate();
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "raf",
|
||||
"repo": "component/raf",
|
||||
"description": "request animation frame",
|
||||
"version": "1.2.0",
|
||||
"keywords": [
|
||||
"animate",
|
||||
"requestAnimationFrame",
|
||||
"performance"
|
||||
],
|
||||
"dependencies": {},
|
||||
"development": {},
|
||||
"scripts": [
|
||||
"index.js"
|
||||
]
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
|
||||
<style>
|
||||
body {
|
||||
padding: 50px;
|
||||
}
|
||||
canvas {
|
||||
border: 1px solid #eee;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="build/build.js"></script>
|
||||
|
||||
<canvas width=900 height=300></canvas>
|
||||
|
||||
<script>
|
||||
var x = 0;
|
||||
var y = 50;
|
||||
var canvas = document.querySelector('canvas');
|
||||
var ctx = canvas.getContext('2d');
|
||||
var raf = require('raf');
|
||||
|
||||
function animate() {
|
||||
raf(animate);
|
||||
draw();
|
||||
}
|
||||
|
||||
var prev = Date.now();
|
||||
function draw() {
|
||||
var curr = Date.now();
|
||||
var diff = curr - prev;
|
||||
var p = diff / 16;
|
||||
ctx.clearRect(0, 0, 900, 300);
|
||||
ctx.beginPath();
|
||||
ctx.globalAlpha = .5;
|
||||
ctx.arc(x, y, 10, 0, Math.PI * 2, false);
|
||||
ctx.fill();
|
||||
x += 2;
|
||||
y += Math.sin(x/20) * 5;
|
||||
prev = curr;
|
||||
}
|
||||
|
||||
animate();
|
||||
</script>
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Expose `requestAnimationFrame()`.
|
||||
*/
|
||||
|
||||
exports = module.exports = window.requestAnimationFrame
|
||||
|| window.webkitRequestAnimationFrame
|
||||
|| window.mozRequestAnimationFrame
|
||||
|| fallback;
|
||||
|
||||
/**
|
||||
* Fallback implementation.
|
||||
*/
|
||||
|
||||
var prev = new Date().getTime();
|
||||
function fallback(fn) {
|
||||
var curr = new Date().getTime();
|
||||
var ms = Math.max(0, 16 - (curr - prev));
|
||||
var req = setTimeout(fn, ms);
|
||||
prev = curr;
|
||||
return req;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel.
|
||||
*/
|
||||
|
||||
var cancel = window.cancelAnimationFrame
|
||||
|| window.webkitCancelAnimationFrame
|
||||
|| window.mozCancelAnimationFrame
|
||||
|| window.clearTimeout;
|
||||
|
||||
exports.cancel = function(id){
|
||||
cancel.call(window, id);
|
||||
};
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "component-raf",
|
||||
"description": "request animation frame",
|
||||
"version": "1.2.0",
|
||||
"keywords": [
|
||||
"animate",
|
||||
"requestAnimationFrame",
|
||||
"performance"
|
||||
],
|
||||
"dependencies": {},
|
||||
"component": {
|
||||
"scripts": {
|
||||
"raf/index.js": "index.js"
|
||||
}
|
||||
},
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/component/raf.git"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user