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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179 | 1×
1×
1×
1×
200×
1×
15×
15×
15×
15×
15×
15×
15×
15×
9×
6×
15×
15×
15×
15×
15×
15×
15×
15×
15×
2200×
2200×
2200×
2200×
22×
2178×
2200×
2200×
2×
2×
2×
2×
1×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
16×
4×
4×
2×
2×
2×
2×
2×
2×
2×
2×
16×
16×
179×
179×
179×
179×
179×
179×
179×
11×
11×
168×
168×
179×
7×
2×
7×
7×
172×
8×
8×
164×
164×
15×
7×
2×
5×
8×
4×
4×
4×
4×
15×
15×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-base", "../model/constant", "../utils/helper", "../utils/helper"], function (require, exports, ej2_base_1, constant_1, helper_1, helper_2) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Animations = (function () {
function Animations(gauge) {
this.gauge = gauge;
}
Animations.prototype.performMarkerAnimation = function (element, axis, pointer) {
var _this = this;
var markerElement = element;
var options;
var timeStamp;
var range = axis.visibleRange;
var rectHeight = (this.gauge.orientation === 'Vertical') ? axis.lineBounds.height : axis.lineBounds.width;
var rectY = (this.gauge.orientation === 'Vertical') ? axis.lineBounds.y : axis.lineBounds.x;
if (this.gauge.orientation === 'Vertical') {
pointer.bounds.y = (helper_1.valueToCoefficient(pointer.currentValue, axis, this.gauge.orientation, range) * rectHeight) + rectY;
}
else {
pointer.bounds.x = (helper_1.valueToCoefficient(pointer.currentValue, axis, this.gauge.orientation, range) * rectHeight) + rectY;
}
options = new helper_1.PathOption(markerElement.id, null, null, null);
options = helper_2.calculateShapes(pointer.bounds, pointer.markerType, new helper_1.Size(pointer.width, pointer.height), pointer.imageUrl, options, this.gauge.orientation, axis, pointer);
var currentValue;
var start = pointer.startValue;
var end = pointer.currentValue;
start = (start === end) ? range.min : start;
var val = Math.abs(start - end);
var currentPath = options.d;
new ej2_base_1.Animation({}).animate(markerElement, {
duration: pointer.animationDuration,
progress: function (args) {
Eif (args.timeStamp >= args.delay) {
timeStamp = ((args.timeStamp - args.delay) / args.duration);
currentValue = (start < end) ? start + (timeStamp * val) : start - (timeStamp * val);
if (_this.gauge.orientation === 'Vertical') {
pointer.bounds.y = (helper_1.valueToCoefficient(currentValue, axis, _this.gauge.orientation, range) *
rectHeight) + rectY;
}
else {
pointer.bounds.x = (helper_1.valueToCoefficient(currentValue, axis, _this.gauge.orientation, range) *
rectHeight) + rectY;
}
options = helper_2.calculateShapes(pointer.bounds, pointer.markerType, new helper_1.Size(pointer.width, pointer.height), pointer.imageUrl, options, _this.gauge.orientation, axis, pointer);
markerElement.setAttribute('d', options.d);
}
},
end: function (model) {
markerElement.setAttribute('d', currentPath);
pointer.startValue = pointer.currentValue;
pointer.animationComplete = true;
_this.gauge.trigger(constant_1.animationComplete, { axis: axis, pointer: pointer });
}
});
};
Animations.prototype.performBarAnimation = function (element, axis, pointer) {
var _this = this;
var val;
var radix = 10;
var timeStamp;
var value2;
var value1;
var height;
var currentValue;
var clipHeight;
var clipY;
var clipX;
var clipVal;
var rectHeight;
var rectY;
var rectX;
var rectWidth;
var clipWidth;
var currentHeight;
var clipElement;
var range = axis.visibleRange;
var pointerElement = element;
var pathElement;
var svgPathElement;
var clipRect;
var lineHeight = (this.gauge.orientation === 'Vertical') ? axis.lineBounds.height : axis.lineBounds.width;
var lineY = (this.gauge.orientation === 'Vertical') ? axis.lineBounds.y : axis.lineBounds.x;
var size = new helper_1.Size(this.gauge.availableSize.width, this.gauge.availableSize.height);
var start = pointer.startValue;
var end = pointer.currentValue;
start = (start === end) ? range.min : start;
var path = '';
var currentPath = '';
var tagName = pointerElement.tagName;
val = Math.abs(start - end);
var pointerValue = (helper_1.valueToCoefficient(end, axis, this.gauge.orientation, range) * lineHeight) + lineY;
var startPointerVal = (helper_1.valueToCoefficient(range.min, axis, this.gauge.orientation, range) *
lineHeight) + lineY;
rectY = (this.gauge.orientation === 'Vertical') ? !axis.isInversed ? pointerValue : startPointerVal :
axis.isInversed ? pointerValue : startPointerVal;
rectHeight = Math.abs(startPointerVal - pointerValue);
if (this.gauge.container.type === 'Thermometer' && start === 0) {
clipElement = pointerElement.parentElement.childNodes[1].childNodes[0].childNodes[0];
if (this.gauge.orientation === 'Vertical') {
clipY = clipElement.getAttribute('y');
clipHeight = clipElement.getAttribute('height');
clipVal = parseInt(clipY, radix) + parseInt(clipHeight, radix);
clipElement.setAttribute('y', clipVal.toString());
}
else {
clipX = clipElement.getAttribute('x');
clipWidth = clipElement.getAttribute('width');
clipVal = parseInt(clipX, radix) + parseInt(clipWidth, radix);
clipElement.setAttribute('width', '0');
}
}
path = helper_2.getBox(pointer.bounds, this.gauge.container.type, this.gauge.orientation, new helper_1.Size(pointer.bounds.width, pointer.bounds.height), 'bar', this.gauge.container.width, axis, pointer.roundedCornerRadius);
new ej2_base_1.Animation({}).animate(pointerElement, {
duration: pointer.animationDuration,
progress: function (animate) {
Eif (animate.timeStamp >= animate.delay) {
timeStamp = ((animate.timeStamp - animate.delay) / animate.duration);
currentValue = (start < end) ? start + (timeStamp * val) : start - (timeStamp * val);
value2 = (helper_1.valueToCoefficient(currentValue, axis, _this.gauge.orientation, range) * lineHeight) + lineY;
value1 = (helper_1.valueToCoefficient(range.min, axis, _this.gauge.orientation, range) * lineHeight) + lineY;
currentHeight = Math.abs(value2 - value1);
if (_this.gauge.orientation === 'Vertical') {
pointer.bounds.y = (!axis.isInversed) ? value2 : value1;
pointer.bounds.height = currentHeight;
}
else {
pointer.bounds.x = (axis.isInversed) ? value2 : value1;
pointer.bounds.width = currentHeight;
}
if (tagName === 'path') {
if (start === 0 && _this.gauge.container.type === 'Thermometer') {
(_this.gauge.orientation === 'Vertical') ?
clipElement.setAttribute('y', (clipVal - (timeStamp * parseInt(clipHeight, radix))).toString()) :
clipElement.setAttribute('width', (timeStamp * parseInt(clipWidth, radix)).toString());
}
currentPath = helper_2.getBox(pointer.bounds, _this.gauge.container.type, _this.gauge.orientation, new helper_1.Size(pointer.bounds.width, pointer.bounds.height), 'bar', _this.gauge.container.width, axis, pointer.roundedCornerRadius);
pointerElement.setAttribute('d', currentPath);
}
else {
if (_this.gauge.orientation === 'Vertical') {
pointerElement.setAttribute('y', pointer.bounds.y.toString());
pointerElement.setAttribute('height', pointer.bounds.height.toString());
}
else {
pointerElement.setAttribute('x', pointer.bounds.x.toString());
pointerElement.setAttribute('width', pointer.bounds.width.toString());
}
}
}
},
end: function (model) {
if (tagName === 'path') {
if (start === 0 && _this.gauge.container.type === 'Thermometer') {
pointerElement.parentElement.children[1].remove();
}
else {
pointerElement.setAttribute('d', path);
}
}
else {
if (_this.gauge.orientation === 'Vertical') {
pointerElement.setAttribute('y', rectY.toString());
pointerElement.setAttribute('height', rectHeight.toString());
}
else {
pointerElement.setAttribute('x', rectY.toString());
pointerElement.setAttribute('width', rectHeight.toString());
}
}
pointer.startValue = pointer.currentValue;
_this.gauge.trigger(constant_1.animationComplete, { axis: axis, pointer: pointer });
}
});
};
return Animations;
}());
exports.Animations = Animations;
});
|