1
- import { CanvasKeyframe , canvasPath } from "../public/animate" ;
1
+ import { CanvasKeyframe , canvasPath , wigglePreset } from "../public/animate" ;
2
2
import { colors } from "./internal/layout" ;
3
3
4
4
// Fetch reference to example container.
@@ -37,6 +37,20 @@ requestAnimationFrame(renderFrame);
37
37
// Extra points that increases when blob gets clicked.
38
38
let extraPoints = 0 ;
39
39
40
+ const genWiggle = ( transition : number ) => {
41
+ wigglePreset (
42
+ animation ,
43
+ {
44
+ extraPoints : 3 + extraPoints ,
45
+ randomness : 1.5 ,
46
+ seed : Math . random ( ) ,
47
+ size,
48
+ } ,
49
+ { } ,
50
+ { speed : 1 , initialTransition : transition , initialTimingFunction : "ease" } ,
51
+ ) ;
52
+ } ;
53
+
40
54
// Generate a keyframe with overridable default values.
41
55
const genFrame = ( overrides : any = { } ) : CanvasKeyframe => {
42
56
const blobOptions = {
@@ -58,7 +72,7 @@ const genFrame = (overrides: any = {}): CanvasKeyframe => {
58
72
// Callback for every frame which starts transition to a new frame.
59
73
const loopAnimation = ( ) : void => {
60
74
extraPoints = 0 ;
61
- animation . transition ( genFrame ( ) ) ;
75
+ genWiggle ( 4000 ) ;
62
76
} ;
63
77
64
78
// Quickly animate to a new frame when canvas is clicked.
@@ -72,7 +86,7 @@ canvas.onclick = () => {
72
86
// Immediately show a new frame.
73
87
window . addEventListener ( "load" , ( ) => {
74
88
resize ( ) ;
75
- animation . transition ( genFrame ( { duration : 0 } ) ) ;
89
+ genWiggle ( 0 ) ;
76
90
} ) ;
77
91
78
92
// Make blob a circle while window is being resized.
0 commit comments