draw-point.js
1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var isFn = function (x) {
return typeof x === 'function';
};
/**
* draw - Handles the drawing of a point.
* TODO: add type checking.
*
* @param {object} params Parameters.
* @return {undefined} Returns undefined.
*/
var draw = function draw(params) {
var point = this,
graphic = point.graphic,
animate = params.animate,
attr = params.attr,
onComplete = params.onComplete,
css = params.css,
group = params.group,
renderer = params.renderer,
shape = params.shapeArgs,
type = params.shapeType;
if (point.shouldDraw()) {
if (!graphic) {
point.graphic = graphic = renderer[type](shape).add(group);
}
graphic.css(css).attr(attr).animate(animate, undefined, onComplete);
} else if (graphic) {
graphic.animate(animate, undefined, function () {
point.graphic = graphic = graphic.destroy();
if (isFn(onComplete)) {
onComplete();
}
});
}
if (graphic) {
graphic.addClass(point.getClassName(), true);
}
};
export default draw;