|
1 | 1 | snabbt.js
|
2 |
| -======== |
| 2 | +========= |
3 | 3 | Fast animations with Javascript(Work in progress)
|
4 | 4 |
|
5 |
| -- [Demo](http://daniel-lundin.github.io/snabbt.js/) |
6 |
| -- [Stress test](http://daniel-lundin.github.io/snabbt.js/sticks.html) |
7 |
| -- [Stress test (mobile)] (http://daniel-lundin.github.io/snabbt.js/sticks_mobile.html) |
8 |
| - |
9 |
| -Basic usage |
10 |
| ------------ |
11 |
| - snabbt(element, { |
12 |
| - position: [100, 0, 0], |
13 |
| - from_rotation: [-Math.PI, 0, 0], |
14 |
| - duration: 700, |
15 |
| - }); |
16 |
| - |
17 |
| - |
18 |
| -Chaining animations |
19 |
| -------------------- |
20 |
| -Animation can be chained by using the `then()`-method on the returned animation object. all from_xxx properties will be set to the end state of the previous animation. |
21 |
| - |
22 |
| - snabbt(element, { |
23 |
| - position: [100, 0, 0], |
24 |
| - duration: 500, |
25 |
| - easing: 'cos', |
26 |
| - }).then({ |
27 |
| - position: [100, 100, 0], |
28 |
| - from_rotation: [0, 0, -Math.PI], |
29 |
| - rotation: [0, 0, Math.PI], |
30 |
| - duration: 1000, |
31 |
| - delay: 500, |
32 |
| - callback: function() { console.log('animation done'); } |
33 |
| - }); |
34 |
| - |
35 |
| - |
36 |
| -Options |
37 |
| -------- |
38 |
| - |
39 |
| -- `from_position`: Start position ([x, y, z]) |
40 |
| -- `position`: End position |
41 |
| -- `from_rotation`: Start rotation ([a, b, c]) |
42 |
| -- `rotation`: End rotation |
43 |
| -- `from_scale`: Start scale ([x, y]) |
44 |
| -- `scale`: End scale |
45 |
| -- `from_rotation_post`: Start rotation applied after `position` and `rotation` ([a, b, c]) |
46 |
| -- `rotation_post`: End rotation applied after `position` and `rotation` |
47 |
| -- `from_width`: Start width in pixels (single value) |
48 |
| -- `width`: End width in pixels |
49 |
| -- `from_height`: Start height in pixels (single value) |
50 |
| -- `height`: End height in pixels |
51 |
| -- `duration`: Animation duration in ms. |
52 |
| -- `delay`: Delay before the animation is started in ms. |
53 |
| -- `easing`: Easing function. |
54 |
| -- `loop`: Repeat animation. Use Infinity for infinite looping. |
55 |
| -- `callback`: Function to be called when the animation is completed |
56 |
| - |
57 |
| - |
58 |
| -Easing functions |
59 |
| ----------------- |
60 |
| -The following easing function are present: |
61 |
| - |
62 |
| - - 'linear' |
63 |
| - - 'cos' |
64 |
| - - 'cos' |
65 |
| - - 'atan' |
66 |
| - - 'sinc_wobbler' |
67 |
| - - 'linear' |
68 |
| - - 'square' |
69 |
| - - 'sqrt' |
70 |
| - - 'cos' |
71 |
| - - 'exp_cos_bounce' |
72 |
| - - 'exp_cos' |
73 |
| - - 'sinc_wobbler' |
74 |
| - |
75 |
| - |
76 |
| -Under the hood |
77 |
| --------------- |
78 |
| -All animations are calculated with matrix multiplications and then set via matrix3d transforms. |
| 5 | +- [Docs](http://daniel-lundin.github.io/snabbt.js/) |
| 6 | +- [Demo](http://daniel-lundin.github.io/snabbt.js/sticks.html) |
| 7 | +- [Demo (mobile)] (http://daniel-lundin.github.io/snabbt.js/sticks_mobile.html) |
0 commit comments