-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
ShapeElement.js
76 lines (71 loc) · 1.88 KB
/
ShapeElement.js
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import ProcessedElement from './helpers/shapes/ProcessedElement';
function IShapeElement() {
}
IShapeElement.prototype = {
addShapeToModifiers: function (data) {
var i;
var len = this.shapeModifiers.length;
for (i = 0; i < len; i += 1) {
this.shapeModifiers[i].addShape(data);
}
},
isShapeInAnimatedModifiers: function (data) {
var i = 0;
var len = this.shapeModifiers.length;
while (i < len) {
if (this.shapeModifiers[i].isAnimatedWithShape(data)) {
return true;
}
}
return false;
},
renderModifiers: function () {
if (!this.shapeModifiers.length) {
return;
}
var i;
var len = this.shapes.length;
for (i = 0; i < len; i += 1) {
this.shapes[i].sh.reset();
}
len = this.shapeModifiers.length;
var shouldBreakProcess;
for (i = len - 1; i >= 0; i -= 1) {
shouldBreakProcess = this.shapeModifiers[i].processShapes(this._isFirstFrame);
// workaround to fix cases where a repeater resets the shape so the following processes get called twice
// TODO: find a better solution for this
if (shouldBreakProcess) {
break;
}
}
},
searchProcessedElement: function (elem) {
var elements = this.processedElements;
var i = 0;
var len = elements.length;
while (i < len) {
if (elements[i].elem === elem) {
return elements[i].pos;
}
i += 1;
}
return 0;
},
addProcessedElement: function (elem, pos) {
var elements = this.processedElements;
var i = elements.length;
while (i) {
i -= 1;
if (elements[i].elem === elem) {
elements[i].pos = pos;
return;
}
}
elements.push(new ProcessedElement(elem, pos));
},
prepareFrame: function (num) {
this.prepareRenderableFrame(num);
this.prepareProperties(num, this.isInRange);
},
};
export default IShapeElement;