You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provides animation along bezier and circular arcs.
5
+
6
+
The animation engine in jQuery is focussed on single dimensional animation - hence it's difficult to animate two variables along a path.
7
+
8
+
This simple plugin provides a method of multidimensional animation, and in particular provides a method for animating along bezier curves and arcs.
9
+
10
+
Bezier
11
+
---
12
+
13
+
Example: animate along a bezier path
14
+
15
+
<pre>
16
+
var bezier_params = {
17
+
start: {
18
+
x: 185,
19
+
y: 185,
20
+
angle: 10
21
+
},
22
+
end: {
23
+
x:540,
24
+
y:110,
25
+
angle: -10,
26
+
length: 0.25
27
+
}
28
+
}
29
+
30
+
$("my_elem").animate({path : new $.path.bezier(bezier_params)})
31
+
</pre>
32
+
33
+
Bezier curves are made form a start point, an end point each with a control point
34
+
35
+
* start is starting point
36
+
* end is the final point
37
+
* x,y indicate the coordinates at that point. Required
38
+
* angle is the angle of the control point from the line joining the start and end. Optional, default is 0
39
+
* length is the distance from the point to it's control point as a ratio of the distance from start to end. Optional, default is 1/3
40
+
41
+
Arc
42
+
---
43
+
44
+
Exampe: animate along an arc
45
+
46
+
<pre>
47
+
48
+
var arc_params = {
49
+
center: [285,185],
50
+
radius: 100,
51
+
start: 30,
52
+
end: 200,
53
+
dir: -1
54
+
}
55
+
56
+
$("my_elem").animate({path : new $.path.arc(arc_params)})
57
+
</pre>
58
+
59
+
* center is the coords of the centre of an imaginary circle that contains the start and end point
60
+
* radius is the radius of this circle
61
+
* start is the angle of the start point. 0 is "North", measured clockwise
62
+
* end is the angle of the start point. 0 is "North", measured clockwise
63
+
* dir is the direction to move in. Only required if not obvious from start and end (e.g. if start is 100, end is 30, but you want to animate clockwise)
64
+
65
+
Other Paths
66
+
----
67
+
68
+
It is trivial to create other paths, or even animate other parameters. E.g:
69
+
70
+
<code>
71
+
72
+
var SineWave = function() {
73
+
this.css = function(p) {
74
+
var s = Math.sin(p*20)
75
+
var x = 500 - p * 300
76
+
var y = s * 50 + 150
77
+
var o = ((s+2)/4+0.1)
78
+
return {top: y + "px", left: x + "px", opacity: o}
79
+
}
80
+
};
81
+
82
+
$("my_elem").animate({path : new SineWave})
83
+
</code>
84
+
85
+
Links
86
+
----
87
+
88
+
* Demo at http://weepy.github.com/jquery.path
89
+
* Source at http://github.com/weepy/jquery.path
90
+
* Issue Tracker at http://github.com/weepy/jquery.path/issues
0 commit comments