@antv/g 1.0.0-alpha.20 → 1.0.0-alpha.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/Canvas.d.ts +40 -18
- package/es/Canvas.js +121 -65
- package/es/DisplayObjectPool.d.ts +2 -1
- package/es/DisplayObjectPool.js +4 -0
- package/{lib → es/camera}/Camera.d.ts +6 -3
- package/es/{Camera.js → camera/Camera.js} +22 -16
- package/es/{Landmark.d.ts → camera/Landmark.d.ts} +2 -2
- package/es/{Landmark.js → camera/Landmark.js} +1 -1
- package/es/camera/index.d.ts +2 -0
- package/es/camera/index.js +2 -0
- package/es/components/Cullable.js +1 -1
- package/es/components/Geometry.d.ts +8 -1
- package/es/components/Renderable.d.ts +9 -8
- package/es/components/Renderable.js +2 -6
- package/es/components/Sortable.d.ts +6 -2
- package/es/display-objects/Circle.d.ts +2 -3
- package/es/display-objects/Circle.js +2 -5
- package/es/{CustomElement.d.ts → display-objects/CustomElement.d.ts} +1 -1
- package/es/{CustomElement.js → display-objects/CustomElement.js} +22 -12
- package/{lib → es/display-objects}/DisplayObject.d.ts +136 -141
- package/es/{DisplayObject.js → display-objects/DisplayObject.js} +408 -292
- package/es/display-objects/Ellipse.d.ts +2 -3
- package/es/display-objects/Ellipse.js +2 -5
- package/es/display-objects/Group.d.ts +2 -1
- package/es/display-objects/Group.js +13 -5
- package/es/display-objects/HTML.d.ts +2 -2
- package/es/display-objects/HTML.js +4 -7
- package/es/display-objects/Image.d.ts +2 -2
- package/es/display-objects/Image.js +2 -6
- package/es/display-objects/Line.d.ts +2 -2
- package/es/display-objects/Line.js +8 -8
- package/es/display-objects/Path.d.ts +3 -2
- package/es/display-objects/Path.js +8 -8
- package/es/display-objects/Polygon.d.ts +2 -2
- package/es/display-objects/Polygon.js +2 -6
- package/es/display-objects/Polyline.d.ts +2 -2
- package/es/display-objects/Polyline.js +8 -8
- package/es/display-objects/Rect.d.ts +2 -2
- package/es/display-objects/Rect.js +2 -6
- package/es/display-objects/Text.d.ts +2 -3
- package/es/display-objects/Text.js +8 -7
- package/es/display-objects/index.d.ts +2 -0
- package/es/display-objects/index.js +2 -0
- package/es/{Animation.d.ts → dom/Animation.d.ts} +3 -3
- package/es/{Animation.js → dom/Animation.js} +2 -3
- package/{lib → es/dom}/AnimationEffectTiming.d.ts +2 -0
- package/es/{AnimationEffectTiming.js → dom/AnimationEffectTiming.js} +3 -2
- package/es/{AnimationEvent.d.ts → dom/AnimationEvent.d.ts} +3 -2
- package/es/{AnimationEvent.js → dom/AnimationEvent.js} +1 -1
- package/es/{Timeline.d.ts → dom/AnimationTimeline.d.ts} +1 -1
- package/es/{Timeline.js → dom/AnimationTimeline.js} +1 -1
- package/es/dom/CustomElementRegistry.d.ts +15 -0
- package/es/dom/CustomElementRegistry.js +40 -0
- package/{lib → es/dom}/CustomEvent.d.ts +1 -1
- package/es/{CustomEvent.js → dom/CustomEvent.js} +1 -1
- package/es/dom/Document.d.ts +36 -17
- package/es/dom/Document.js +98 -14
- package/es/dom/Element.d.ts +71 -92
- package/es/dom/Element.js +179 -195
- package/es/dom/EventTarget.d.ts +11 -6
- package/es/dom/EventTarget.js +12 -4
- package/es/dom/FederatedEvent.d.ts +15 -7
- package/es/dom/FederatedEvent.js +33 -0
- package/es/dom/FederatedMouseEvent.d.ts +1 -1
- package/es/{KeyframeEffect.d.ts → dom/KeyframeEffect.d.ts} +16 -5
- package/es/{KeyframeEffect.js → dom/KeyframeEffect.js} +50 -4
- package/es/{KeyframeList.d.ts → dom/KeyframeList.d.ts} +1 -1
- package/es/{KeyframeList.js → dom/KeyframeList.js} +0 -0
- package/es/dom/Node.d.ts +38 -23
- package/es/dom/Node.js +37 -33
- package/es/dom/index.d.ts +15 -2
- package/es/dom/index.js +16 -3
- package/es/dom/interfaces.d.ts +301 -0
- package/es/dom/interfaces.js +1 -0
- package/es/global-module.d.ts +0 -2
- package/es/global-module.js +31 -29
- package/es/index.d.ts +7 -14
- package/es/index.js +8 -15
- package/es/plugins/CullingPlugin.d.ts +2 -2
- package/es/plugins/CullingPlugin.js +13 -16
- package/es/plugins/DirtyCheckPlugin.d.ts +1 -1
- package/es/plugins/DirtyCheckPlugin.js +8 -7
- package/es/plugins/EventPlugin.js +52 -31
- package/es/plugins/FrustumCullingStrategy.d.ts +1 -1
- package/es/plugins/FrustumCullingStrategy.js +5 -4
- package/es/plugins/PrepareRendererPlugin.d.ts +0 -1
- package/es/plugins/PrepareRendererPlugin.js +42 -38
- package/es/property-handlers/aabb.d.ts +2 -3
- package/es/property-handlers/aabb.js +29 -21
- package/es/property-handlers/anchor.d.ts +3 -0
- package/es/property-handlers/anchor.js +21 -0
- package/es/property-handlers/clipPath.d.ts +1 -1
- package/es/property-handlers/clipPath.js +3 -4
- package/es/property-handlers/color.d.ts +1 -1
- package/es/property-handlers/dimension.d.ts +1 -1
- package/es/property-handlers/dimension.js +6 -9
- package/es/property-handlers/filter.d.ts +1 -1
- package/es/property-handlers/index.d.ts +5 -4
- package/es/property-handlers/index.js +1 -0
- package/es/property-handlers/localPosition.d.ts +1 -1
- package/es/property-handlers/localPosition.js +1 -6
- package/es/property-handlers/offsetDistance.d.ts +1 -1
- package/es/property-handlers/offsetPath.d.ts +1 -1
- package/es/property-handlers/origin.d.ts +1 -1
- package/es/property-handlers/origin.js +9 -2
- package/es/property-handlers/path.d.ts +2 -2
- package/es/property-handlers/path.js +8 -4
- package/es/property-handlers/points.d.ts +1 -1
- package/es/property-handlers/transform.d.ts +1 -1
- package/es/property-handlers/zIndex.d.ts +1 -1
- package/es/services/ContextService.d.ts +3 -2
- package/es/services/EventService.d.ts +18 -13
- package/es/services/EventService.js +604 -384
- package/es/services/RenderingContext.d.ts +1 -1
- package/es/services/RenderingService.d.ts +23 -29
- package/es/services/RenderingService.js +63 -54
- package/es/services/SceneGraphSelector.d.ts +7 -7
- package/es/services/SceneGraphSelector.js +10 -6
- package/es/services/SceneGraphService.d.ts +73 -78
- package/es/services/SceneGraphService.js +165 -78
- package/es/services/aabb/PathUpdater.d.ts +1 -1
- package/es/services/aabb/RectUpdater.d.ts +2 -2
- package/es/services/aabb/interfaces.d.ts +1 -1
- package/es/shapes/Point.d.ts +4 -0
- package/es/shapes/Polygon.d.ts +9 -0
- package/es/shapes/Polygon.js +62 -0
- package/es/shapes/index.d.ts +1 -0
- package/es/shapes/index.js +2 -1
- package/es/types.d.ts +18 -6
- package/es/utils/animation.d.ts +1 -2
- package/es/utils/animation.js +5 -10
- package/es/utils/canvas.d.ts +1 -1
- package/es/utils/custom-easing.d.ts +3 -2
- package/es/utils/custom-easing.js +12 -6
- package/es/utils/event.js +1 -1
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +2 -1
- package/es/utils/interpolation.d.ts +3 -4
- package/es/utils/interpolation.js +0 -16
- package/es/utils/path.d.ts +2 -2
- package/lib/Canvas.d.ts +40 -18
- package/lib/Canvas.js +131 -74
- package/lib/DisplayObjectPool.d.ts +2 -1
- package/lib/DisplayObjectPool.js +4 -0
- package/{es → lib/camera}/Camera.d.ts +6 -3
- package/lib/{Camera.js → camera/Camera.js} +25 -20
- package/lib/{Landmark.d.ts → camera/Landmark.d.ts} +2 -2
- package/lib/{Landmark.js → camera/Landmark.js} +2 -3
- package/lib/camera/index.d.ts +2 -0
- package/lib/camera/index.js +31 -0
- package/lib/components/Cullable.js +1 -1
- package/lib/components/Geometry.d.ts +8 -1
- package/lib/components/Renderable.d.ts +9 -8
- package/lib/components/Renderable.js +2 -6
- package/lib/components/Sortable.d.ts +6 -2
- package/lib/display-objects/Circle.d.ts +2 -3
- package/lib/display-objects/Circle.js +3 -6
- package/lib/{CustomElement.d.ts → display-objects/CustomElement.d.ts} +1 -1
- package/lib/{CustomElement.js → display-objects/CustomElement.js} +22 -12
- package/{es → lib/display-objects}/DisplayObject.d.ts +136 -141
- package/lib/{DisplayObject.js → display-objects/DisplayObject.js} +418 -299
- package/lib/display-objects/Ellipse.d.ts +2 -3
- package/lib/display-objects/Ellipse.js +3 -6
- package/lib/display-objects/Group.d.ts +2 -1
- package/lib/display-objects/Group.js +12 -4
- package/lib/display-objects/HTML.d.ts +2 -2
- package/lib/display-objects/HTML.js +4 -7
- package/lib/display-objects/Image.d.ts +2 -2
- package/lib/display-objects/Image.js +2 -6
- package/lib/display-objects/Line.d.ts +2 -2
- package/lib/display-objects/Line.js +8 -8
- package/lib/display-objects/Path.d.ts +3 -2
- package/lib/display-objects/Path.js +8 -8
- package/lib/display-objects/Polygon.d.ts +2 -2
- package/lib/display-objects/Polygon.js +2 -6
- package/lib/display-objects/Polyline.d.ts +2 -2
- package/lib/display-objects/Polyline.js +8 -8
- package/lib/display-objects/Rect.d.ts +2 -2
- package/lib/display-objects/Rect.js +2 -6
- package/lib/display-objects/Text.d.ts +2 -3
- package/lib/display-objects/Text.js +9 -8
- package/lib/display-objects/index.d.ts +2 -0
- package/lib/display-objects/index.js +26 -0
- package/lib/{Animation.d.ts → dom/Animation.d.ts} +3 -3
- package/lib/{Animation.js → dom/Animation.js} +2 -3
- package/{es → lib/dom}/AnimationEffectTiming.d.ts +2 -0
- package/lib/{AnimationEffectTiming.js → dom/AnimationEffectTiming.js} +3 -3
- package/lib/{AnimationEvent.d.ts → dom/AnimationEvent.d.ts} +3 -2
- package/lib/{AnimationEvent.js → dom/AnimationEvent.js} +1 -1
- package/lib/{Timeline.d.ts → dom/AnimationTimeline.d.ts} +1 -1
- package/lib/{Timeline.js → dom/AnimationTimeline.js} +1 -1
- package/lib/dom/CustomElementRegistry.d.ts +15 -0
- package/lib/dom/CustomElementRegistry.js +48 -0
- package/{es → lib/dom}/CustomEvent.d.ts +1 -1
- package/lib/{CustomEvent.js → dom/CustomEvent.js} +1 -1
- package/lib/dom/Document.d.ts +36 -17
- package/lib/dom/Document.js +99 -15
- package/lib/dom/Element.d.ts +71 -92
- package/lib/dom/Element.js +180 -198
- package/lib/dom/EventTarget.d.ts +11 -6
- package/lib/dom/EventTarget.js +20 -10
- package/lib/dom/FederatedEvent.d.ts +15 -7
- package/lib/dom/FederatedEvent.js +33 -0
- package/lib/dom/FederatedMouseEvent.d.ts +1 -1
- package/lib/{KeyframeEffect.d.ts → dom/KeyframeEffect.d.ts} +16 -5
- package/lib/{KeyframeEffect.js → dom/KeyframeEffect.js} +50 -4
- package/lib/{KeyframeList.d.ts → dom/KeyframeList.d.ts} +1 -1
- package/lib/{KeyframeList.js → dom/KeyframeList.js} +0 -0
- package/lib/dom/Node.d.ts +38 -23
- package/lib/dom/Node.js +37 -33
- package/lib/dom/index.d.ts +15 -2
- package/lib/dom/index.js +177 -8
- package/lib/dom/interfaces.d.ts +301 -0
- package/lib/dom/interfaces.js +5 -0
- package/lib/global-module.d.ts +0 -2
- package/lib/global-module.js +30 -30
- package/lib/index.d.ts +7 -14
- package/lib/index.js +44 -135
- package/lib/plugins/CullingPlugin.d.ts +2 -2
- package/lib/plugins/CullingPlugin.js +14 -16
- package/lib/plugins/DirtyCheckPlugin.d.ts +1 -1
- package/lib/plugins/DirtyCheckPlugin.js +9 -7
- package/lib/plugins/EventPlugin.js +52 -30
- package/lib/plugins/FrustumCullingStrategy.d.ts +1 -1
- package/lib/plugins/FrustumCullingStrategy.js +5 -4
- package/lib/plugins/PrepareRendererPlugin.d.ts +0 -1
- package/lib/plugins/PrepareRendererPlugin.js +41 -37
- package/lib/property-handlers/aabb.d.ts +2 -3
- package/lib/property-handlers/aabb.js +28 -22
- package/lib/property-handlers/anchor.d.ts +3 -0
- package/lib/property-handlers/anchor.js +34 -0
- package/lib/property-handlers/clipPath.d.ts +1 -1
- package/lib/property-handlers/clipPath.js +3 -4
- package/lib/property-handlers/color.d.ts +1 -1
- package/lib/property-handlers/dimension.d.ts +1 -1
- package/lib/property-handlers/dimension.js +6 -9
- package/lib/property-handlers/filter.d.ts +1 -1
- package/lib/property-handlers/index.d.ts +5 -4
- package/lib/property-handlers/index.js +14 -0
- package/lib/property-handlers/localPosition.d.ts +1 -1
- package/lib/property-handlers/localPosition.js +1 -7
- package/lib/property-handlers/offsetDistance.d.ts +1 -1
- package/lib/property-handlers/offsetPath.d.ts +1 -1
- package/lib/property-handlers/origin.d.ts +1 -1
- package/lib/property-handlers/origin.js +10 -2
- package/lib/property-handlers/path.d.ts +2 -2
- package/lib/property-handlers/path.js +8 -4
- package/lib/property-handlers/points.d.ts +1 -1
- package/lib/property-handlers/transform.d.ts +1 -1
- package/lib/property-handlers/zIndex.d.ts +1 -1
- package/lib/services/ContextService.d.ts +3 -2
- package/lib/services/EventService.d.ts +18 -13
- package/lib/services/EventService.js +616 -385
- package/lib/services/RenderingContext.d.ts +1 -1
- package/lib/services/RenderingService.d.ts +23 -29
- package/lib/services/RenderingService.js +66 -56
- package/lib/services/SceneGraphSelector.d.ts +7 -7
- package/lib/services/SceneGraphSelector.js +10 -6
- package/lib/services/SceneGraphService.d.ts +73 -78
- package/lib/services/SceneGraphService.js +166 -79
- package/lib/services/aabb/PathUpdater.d.ts +1 -1
- package/lib/services/aabb/RectUpdater.d.ts +2 -2
- package/lib/services/aabb/interfaces.d.ts +1 -1
- package/lib/shapes/Point.d.ts +4 -0
- package/lib/shapes/Polygon.d.ts +9 -0
- package/lib/shapes/Polygon.js +69 -0
- package/lib/shapes/index.d.ts +1 -0
- package/lib/shapes/index.js +13 -0
- package/lib/types.d.ts +18 -6
- package/lib/utils/animation.d.ts +1 -2
- package/lib/utils/animation.js +8 -16
- package/lib/utils/canvas.d.ts +1 -1
- package/lib/utils/custom-easing.d.ts +3 -2
- package/lib/utils/custom-easing.js +16 -8
- package/lib/utils/event.js +1 -1
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +13 -0
- package/lib/utils/interpolation.d.ts +3 -4
- package/lib/utils/interpolation.js +0 -17
- package/lib/utils/path.d.ts +2 -2
- package/package.json +6 -6
- package/es/Batch.d.ts +0 -25
- package/es/Batch.js +0 -82
- package/es/shapes-type.d.ts +0 -175
- package/es/shapes-type.js +0 -18
- package/es/utils/matrix-decompose.d.ts +0 -3
- package/es/utils/matrix-decompose.js +0 -404
- package/lib/Batch.d.ts +0 -25
- package/lib/Batch.js +0 -91
- package/lib/shapes-type.d.ts +0 -175
- package/lib/shapes-type.js +0 -41
- package/lib/utils/matrix-decompose.d.ts +0 -3
- package/lib/utils/matrix-decompose.js +0 -414
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { __decorate,
|
|
1
|
+
import { __decorate, __metadata, __read, __spreadArray } from "tslib";
|
|
2
2
|
import { isNil } from '@antv/util';
|
|
3
|
-
import { EventEmitter } from 'eventemitter3';
|
|
4
3
|
import { Transform } from '../components/Transform';
|
|
5
4
|
import { Sortable } from '../components/Sortable';
|
|
6
5
|
import { inject, injectable } from 'inversify';
|
|
7
6
|
import { Geometry, Renderable } from '../components';
|
|
8
7
|
import { mat4, quat, vec3 } from 'gl-matrix';
|
|
9
|
-
import { AABB } from '../shapes';
|
|
8
|
+
import { AABB, Rectangle } from '../shapes';
|
|
10
9
|
import { SceneGraphSelectorFactory } from './SceneGraphSelector';
|
|
10
|
+
import { ElementEvent } from '..';
|
|
11
11
|
export function sortByZIndex(o1, o2) {
|
|
12
12
|
var zIndex1 = Number(o1.style.zIndex);
|
|
13
13
|
var zIndex2 = Number(o2.style.zIndex);
|
|
14
14
|
|
|
15
15
|
if (zIndex1 === zIndex2) {
|
|
16
|
+
// return o1.entity.getComponent(Sortable).lastSortedIndex - o2.entity.getComponent(Sortable).lastSortedIndex;
|
|
16
17
|
var parent_1 = o1.parentNode;
|
|
17
18
|
|
|
18
19
|
if (parent_1) {
|
|
@@ -23,12 +24,29 @@ export function sortByZIndex(o1, o2) {
|
|
|
23
24
|
|
|
24
25
|
return zIndex1 - zIndex2;
|
|
25
26
|
}
|
|
26
|
-
export
|
|
27
|
+
export function dirtifyRenderable(element, silent) {
|
|
28
|
+
if (silent === void 0) {
|
|
29
|
+
silent = false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var node = element;
|
|
33
|
+
|
|
34
|
+
while (node) {
|
|
35
|
+
var renderable = node.entity.getComponent(Renderable);
|
|
36
|
+
|
|
37
|
+
if (renderable) {
|
|
38
|
+
renderable.renderBoundsDirty = true;
|
|
39
|
+
renderable.boundsDirty = true;
|
|
40
|
+
renderable.dirty = true;
|
|
41
|
+
}
|
|
27
42
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
})(SCENE_GRAPH_EVENT || (SCENE_GRAPH_EVENT = {}));
|
|
43
|
+
node = node.parentElement;
|
|
44
|
+
}
|
|
31
45
|
|
|
46
|
+
if (!silent) {
|
|
47
|
+
element.emit(ElementEvent.BOUNDS_CHANGED, {});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
32
50
|
export var SceneGraphService = 'SceneGraphService';
|
|
33
51
|
/**
|
|
34
52
|
* update transform in scene graph
|
|
@@ -36,11 +54,9 @@ export var SceneGraphService = 'SceneGraphService';
|
|
|
36
54
|
* @see https://community.khronos.org/t/scene-graphs/50542/7
|
|
37
55
|
*/
|
|
38
56
|
|
|
39
|
-
var DefaultSceneGraphService = function (
|
|
40
|
-
__extends(DefaultSceneGraphService, _super);
|
|
41
|
-
|
|
57
|
+
var DefaultSceneGraphService = function () {
|
|
42
58
|
function DefaultSceneGraphService() {
|
|
43
|
-
var _this =
|
|
59
|
+
var _this = this;
|
|
44
60
|
/**
|
|
45
61
|
* compare two display objects by hierarchy-index and z-index
|
|
46
62
|
*
|
|
@@ -49,7 +65,7 @@ var DefaultSceneGraphService = function (_super) {
|
|
|
49
65
|
*/
|
|
50
66
|
|
|
51
67
|
|
|
52
|
-
|
|
68
|
+
this.sort = function (object1, object2) {
|
|
53
69
|
if (!object1.parentNode) {
|
|
54
70
|
return -1;
|
|
55
71
|
}
|
|
@@ -107,7 +123,7 @@ var DefaultSceneGraphService = function (_super) {
|
|
|
107
123
|
*/
|
|
108
124
|
|
|
109
125
|
|
|
110
|
-
|
|
126
|
+
this.rotate = function () {
|
|
111
127
|
var parentInvertRotation = quat.create();
|
|
112
128
|
return function (element, degrees, y, z) {
|
|
113
129
|
if (y === void 0) {
|
|
@@ -152,7 +168,7 @@ var DefaultSceneGraphService = function (_super) {
|
|
|
152
168
|
*/
|
|
153
169
|
|
|
154
170
|
|
|
155
|
-
|
|
171
|
+
this.rotateLocal = function () {
|
|
156
172
|
var rotation = quat.create();
|
|
157
173
|
return function (element, degrees, y, z) {
|
|
158
174
|
if (y === void 0) {
|
|
@@ -181,7 +197,7 @@ var DefaultSceneGraphService = function (_super) {
|
|
|
181
197
|
*/
|
|
182
198
|
|
|
183
199
|
|
|
184
|
-
|
|
200
|
+
this.setEulerAngles = function () {
|
|
185
201
|
var invParentRot = quat.create();
|
|
186
202
|
return function (element, degrees, y, z) {
|
|
187
203
|
if (y === void 0) {
|
|
@@ -223,7 +239,7 @@ var DefaultSceneGraphService = function (_super) {
|
|
|
223
239
|
*/
|
|
224
240
|
|
|
225
241
|
|
|
226
|
-
|
|
242
|
+
this.translateLocal = function () {
|
|
227
243
|
return function (element, translation, y, z) {
|
|
228
244
|
if (y === void 0) {
|
|
229
245
|
y = 0;
|
|
@@ -257,13 +273,13 @@ var DefaultSceneGraphService = function (_super) {
|
|
|
257
273
|
*/
|
|
258
274
|
|
|
259
275
|
|
|
260
|
-
|
|
276
|
+
this.setPosition = function () {
|
|
261
277
|
var parentInvertMatrix = mat4.create();
|
|
262
278
|
return function (element, position) {
|
|
263
279
|
var transform = element.getEntity().getComponent(Transform);
|
|
264
280
|
position = vec3.fromValues(position[0], position[1], position[2] || transform.position[2]);
|
|
265
281
|
|
|
266
|
-
if (vec3.equals(
|
|
282
|
+
if (vec3.equals(_this.getPosition(element), position)) {
|
|
267
283
|
return;
|
|
268
284
|
}
|
|
269
285
|
|
|
@@ -276,8 +292,6 @@ var DefaultSceneGraphService = function (_super) {
|
|
|
276
292
|
mat4.copy(parentInvertMatrix, parentTransform.worldTransform);
|
|
277
293
|
mat4.invert(parentInvertMatrix, parentInvertMatrix);
|
|
278
294
|
vec3.transformMat4(transform.localPosition, position, parentInvertMatrix);
|
|
279
|
-
|
|
280
|
-
_this.dirtifyLocal(element, transform);
|
|
281
295
|
}
|
|
282
296
|
|
|
283
297
|
if (!transform.localDirtyFlag) {
|
|
@@ -299,7 +313,7 @@ var DefaultSceneGraphService = function (_super) {
|
|
|
299
313
|
*/
|
|
300
314
|
|
|
301
315
|
|
|
302
|
-
|
|
316
|
+
this.translate = function () {
|
|
303
317
|
var tr = vec3.create();
|
|
304
318
|
return function (element, translation, y, z) {
|
|
305
319
|
if (y === void 0) {
|
|
@@ -323,8 +337,6 @@ var DefaultSceneGraphService = function (_super) {
|
|
|
323
337
|
_this.setPosition(element, tr);
|
|
324
338
|
};
|
|
325
339
|
}();
|
|
326
|
-
|
|
327
|
-
return _this;
|
|
328
340
|
}
|
|
329
341
|
|
|
330
342
|
DefaultSceneGraphService.prototype.matches = function (query, root) {
|
|
@@ -540,6 +552,10 @@ var DefaultSceneGraphService = function (_super) {
|
|
|
540
552
|
transform = element.getEntity().getComponent(Transform);
|
|
541
553
|
}
|
|
542
554
|
|
|
555
|
+
if (!transform) {
|
|
556
|
+
return mat4.create();
|
|
557
|
+
}
|
|
558
|
+
|
|
543
559
|
if (!transform.localDirtyFlag && !transform.dirtyFlag) {
|
|
544
560
|
return transform.worldTransform;
|
|
545
561
|
}
|
|
@@ -574,64 +590,70 @@ var DefaultSceneGraphService = function (_super) {
|
|
|
574
590
|
|
|
575
591
|
return transform.localTransform;
|
|
576
592
|
};
|
|
577
|
-
/**
|
|
578
|
-
* account for children in local space
|
|
579
|
-
*/
|
|
580
593
|
|
|
594
|
+
DefaultSceneGraphService.prototype.resetLocalTransform = function (element) {
|
|
595
|
+
this.setLocalScale(element, [1, 1, 1]);
|
|
596
|
+
this.setLocalPosition(element, [0, 0, 0]);
|
|
597
|
+
this.setLocalEulerAngles(element, [0, 0, 0]);
|
|
598
|
+
};
|
|
581
599
|
|
|
582
|
-
DefaultSceneGraphService.prototype.
|
|
583
|
-
if (
|
|
584
|
-
|
|
585
|
-
var bounds = this.getBounds(element);
|
|
586
|
-
|
|
587
|
-
if (bounds) {
|
|
588
|
-
var localBounds = new AABB();
|
|
589
|
-
localBounds.setFromTransformedAABB(bounds, parentInvert);
|
|
590
|
-
return localBounds;
|
|
591
|
-
}
|
|
600
|
+
DefaultSceneGraphService.prototype.getTransformedGeometryBounds = function (element, render) {
|
|
601
|
+
if (render === void 0) {
|
|
602
|
+
render = false;
|
|
592
603
|
}
|
|
593
604
|
|
|
594
|
-
|
|
605
|
+
var bounds = this.getGeometryBounds(element, render);
|
|
606
|
+
|
|
607
|
+
if (bounds) {
|
|
608
|
+
var aabb = new AABB();
|
|
609
|
+
aabb.setFromTransformedAABB(bounds, this.getWorldTransform(element));
|
|
610
|
+
return aabb;
|
|
611
|
+
} else {
|
|
612
|
+
return null;
|
|
613
|
+
}
|
|
595
614
|
};
|
|
596
615
|
/**
|
|
597
616
|
* won't account for children
|
|
598
617
|
*/
|
|
599
618
|
|
|
600
619
|
|
|
601
|
-
DefaultSceneGraphService.prototype.getGeometryBounds = function (element) {
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
var aabb = null;
|
|
605
|
-
|
|
606
|
-
if (geometryAABB) {
|
|
607
|
-
aabb = new AABB(); // apply transformation to aabb
|
|
608
|
-
|
|
609
|
-
aabb.setFromTransformedAABB(geometryAABB, this.getWorldTransform(element));
|
|
620
|
+
DefaultSceneGraphService.prototype.getGeometryBounds = function (element, render) {
|
|
621
|
+
if (render === void 0) {
|
|
622
|
+
render = false;
|
|
610
623
|
}
|
|
611
624
|
|
|
612
|
-
|
|
625
|
+
var geometry = element.entity.getComponent(Geometry);
|
|
626
|
+
var bounds = render ? geometry.renderBounds : geometry.contentBounds || null;
|
|
627
|
+
return bounds && new AABB(bounds.center, bounds.halfExtents) || null;
|
|
613
628
|
};
|
|
614
629
|
/**
|
|
615
630
|
* account for children in world space
|
|
616
631
|
*/
|
|
617
632
|
|
|
618
633
|
|
|
619
|
-
DefaultSceneGraphService.prototype.getBounds = function (element) {
|
|
634
|
+
DefaultSceneGraphService.prototype.getBounds = function (element, render) {
|
|
620
635
|
var _this = this;
|
|
621
636
|
|
|
622
|
-
|
|
623
|
-
|
|
637
|
+
if (render === void 0) {
|
|
638
|
+
render = false;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
var renderable = element.entity.getComponent(Renderable);
|
|
624
642
|
|
|
625
|
-
if (!renderable.
|
|
626
|
-
return renderable.
|
|
643
|
+
if (!renderable.boundsDirty && !render && renderable.bounds) {
|
|
644
|
+
return renderable.bounds;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
if (!renderable.renderBoundsDirty && render && renderable.renderBounds) {
|
|
648
|
+
return renderable.renderBounds;
|
|
627
649
|
} // reset with geometry's aabb
|
|
628
650
|
|
|
629
651
|
|
|
630
|
-
var aabb = this.
|
|
652
|
+
var aabb = this.getTransformedGeometryBounds(element, render); // merge children's aabbs
|
|
631
653
|
|
|
632
654
|
var children = element.childNodes;
|
|
633
655
|
children.forEach(function (child) {
|
|
634
|
-
var childBounds = _this.getBounds(child);
|
|
656
|
+
var childBounds = _this.getBounds(child, render);
|
|
635
657
|
|
|
636
658
|
if (childBounds) {
|
|
637
659
|
if (!aabb) {
|
|
@@ -643,44 +665,94 @@ var DefaultSceneGraphService = function (_super) {
|
|
|
643
665
|
}
|
|
644
666
|
}); // account for clip path
|
|
645
667
|
|
|
646
|
-
|
|
647
|
-
|
|
668
|
+
var clipPath = element.style.clipPath;
|
|
669
|
+
|
|
670
|
+
if (clipPath) {
|
|
671
|
+
var clipPathBounds = this.getTransformedGeometryBounds(clipPath, true);
|
|
672
|
+
var transformParentBounds = void 0;
|
|
648
673
|
|
|
649
674
|
if (clipPathBounds) {
|
|
650
|
-
// intersect with original geometry
|
|
651
|
-
|
|
675
|
+
transformParentBounds = new AABB(); // intersect with original geometry
|
|
676
|
+
|
|
677
|
+
transformParentBounds.setFromTransformedAABB(clipPathBounds, this.getWorldTransform(element));
|
|
652
678
|
}
|
|
653
679
|
|
|
654
680
|
if (!aabb) {
|
|
655
|
-
aabb =
|
|
656
|
-
} else if (
|
|
657
|
-
aabb =
|
|
681
|
+
aabb = transformParentBounds;
|
|
682
|
+
} else if (transformParentBounds) {
|
|
683
|
+
aabb = transformParentBounds.intersection(aabb);
|
|
658
684
|
}
|
|
659
685
|
}
|
|
660
686
|
|
|
661
687
|
if (aabb) {
|
|
662
|
-
|
|
688
|
+
if (render) {
|
|
689
|
+
renderable.renderBounds = aabb;
|
|
690
|
+
} else {
|
|
691
|
+
renderable.bounds = aabb;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
if (render) {
|
|
696
|
+
renderable.renderBoundsDirty = false;
|
|
697
|
+
} else {
|
|
698
|
+
renderable.boundsDirty = false;
|
|
663
699
|
}
|
|
664
700
|
|
|
665
|
-
|
|
666
|
-
this.emit(SCENE_GRAPH_EVENT.AABBChanged, element);
|
|
667
|
-
return renderable.aabb || null;
|
|
701
|
+
return aabb || null;
|
|
668
702
|
};
|
|
703
|
+
/**
|
|
704
|
+
* account for children in local space
|
|
705
|
+
*/
|
|
669
706
|
|
|
670
|
-
DefaultSceneGraphService.prototype.dirtifyAABBToRoot = function (element) {
|
|
671
|
-
var p = element;
|
|
672
707
|
|
|
673
|
-
|
|
674
|
-
|
|
708
|
+
DefaultSceneGraphService.prototype.getLocalBounds = function (element) {
|
|
709
|
+
if (element.parentNode) {
|
|
710
|
+
var parentInvert = mat4.create();
|
|
675
711
|
|
|
676
|
-
if (
|
|
677
|
-
|
|
678
|
-
renderable.dirty = true;
|
|
679
|
-
this.emit(SCENE_GRAPH_EVENT.AABBChanged, p);
|
|
712
|
+
if (element.parentNode.entity.hasComponent(Transform)) {
|
|
713
|
+
parentInvert = mat4.invert(mat4.create(), this.getWorldTransform(element.parentNode));
|
|
680
714
|
}
|
|
681
715
|
|
|
682
|
-
|
|
716
|
+
var bounds = this.getBounds(element);
|
|
717
|
+
|
|
718
|
+
if (bounds) {
|
|
719
|
+
var localBounds = new AABB();
|
|
720
|
+
localBounds.setFromTransformedAABB(bounds, parentInvert);
|
|
721
|
+
return localBounds;
|
|
722
|
+
}
|
|
683
723
|
}
|
|
724
|
+
|
|
725
|
+
return this.getBounds(element);
|
|
726
|
+
};
|
|
727
|
+
|
|
728
|
+
DefaultSceneGraphService.prototype.getBoundingClientRect = function (element) {
|
|
729
|
+
var _a, _b;
|
|
730
|
+
|
|
731
|
+
var aabb;
|
|
732
|
+
var bounds = this.getGeometryBounds(element);
|
|
733
|
+
|
|
734
|
+
if (bounds) {
|
|
735
|
+
aabb = new AABB(); // apply transformation to aabb
|
|
736
|
+
|
|
737
|
+
aabb.setFromTransformedAABB(bounds, this.getWorldTransform(element));
|
|
738
|
+
} // calc context's offset
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
var bbox = (_b = (_a = element.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) === null || _b === void 0 ? void 0 : _b.getContextService().getBoundingClientRect();
|
|
742
|
+
|
|
743
|
+
if (aabb) {
|
|
744
|
+
var _c = __read(aabb.getMin(), 2),
|
|
745
|
+
left = _c[0],
|
|
746
|
+
top_1 = _c[1];
|
|
747
|
+
|
|
748
|
+
var _d = __read(aabb.getMax(), 2),
|
|
749
|
+
right = _d[0],
|
|
750
|
+
bottom = _d[1];
|
|
751
|
+
|
|
752
|
+
return new Rectangle(left + ((bbox === null || bbox === void 0 ? void 0 : bbox.left) || 0), top_1 + ((bbox === null || bbox === void 0 ? void 0 : bbox.top) || 0), right - left, bottom - top_1);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
return new Rectangle((bbox === null || bbox === void 0 ? void 0 : bbox.left) || 0, (bbox === null || bbox === void 0 ? void 0 : bbox.top) || 0, 0, 0);
|
|
684
756
|
};
|
|
685
757
|
|
|
686
758
|
DefaultSceneGraphService.prototype.dirtifyWorldInternal = function (element, transform) {
|
|
@@ -693,10 +765,25 @@ var DefaultSceneGraphService = function (_super) {
|
|
|
693
765
|
|
|
694
766
|
if (!childTransform.dirtyFlag) {
|
|
695
767
|
_this.dirtifyWorldInternal(child, childTransform);
|
|
696
|
-
}
|
|
697
|
-
}); // bubble up to root
|
|
768
|
+
} // model matrix changed
|
|
698
769
|
|
|
699
|
-
|
|
770
|
+
|
|
771
|
+
child.emit(ElementEvent.ATTRIBUTE_CHANGED, {
|
|
772
|
+
attributeName: 'modelMatrix',
|
|
773
|
+
oldValue: null,
|
|
774
|
+
newValue: null
|
|
775
|
+
});
|
|
776
|
+
}); // model matrix changed
|
|
777
|
+
|
|
778
|
+
element.emit(ElementEvent.ATTRIBUTE_CHANGED, {
|
|
779
|
+
attributeName: 'modelMatrix',
|
|
780
|
+
oldValue: null,
|
|
781
|
+
newValue: null
|
|
782
|
+
}); // emit on leaf node
|
|
783
|
+
|
|
784
|
+
if (element.childNodes.length === 0) {
|
|
785
|
+
dirtifyRenderable(element);
|
|
786
|
+
}
|
|
700
787
|
}
|
|
701
788
|
};
|
|
702
789
|
|
|
@@ -725,6 +812,6 @@ var DefaultSceneGraphService = function (_super) {
|
|
|
725
812
|
|
|
726
813
|
DefaultSceneGraphService = __decorate([injectable()], DefaultSceneGraphService);
|
|
727
814
|
return DefaultSceneGraphService;
|
|
728
|
-
}(
|
|
815
|
+
}();
|
|
729
816
|
|
|
730
817
|
export { DefaultSceneGraphService };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GeometryAABBUpdater } from './interfaces';
|
|
2
|
-
import type { DisplayObject } from '../../DisplayObject';
|
|
2
|
+
import type { DisplayObject } from '../../display-objects/DisplayObject';
|
|
3
3
|
import type { ParsedBaseStyleProps } from '../../types';
|
|
4
4
|
export declare class PathUpdater implements GeometryAABBUpdater<ParsedBaseStyleProps> {
|
|
5
5
|
update(parsedStyle: ParsedBaseStyleProps, object: DisplayObject): {
|
|
@@ -2,8 +2,8 @@ import type { GeometryAABBUpdater } from './interfaces';
|
|
|
2
2
|
import type { ParsedImageStyleProps } from '../../display-objects/Image';
|
|
3
3
|
export declare class RectUpdater implements GeometryAABBUpdater<ParsedImageStyleProps> {
|
|
4
4
|
update(attributes: ParsedImageStyleProps): {
|
|
5
|
-
width:
|
|
6
|
-
height:
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
7
|
x: number;
|
|
8
8
|
y: number;
|
|
9
9
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DisplayObject } from '../../DisplayObject';
|
|
1
|
+
import { DisplayObject } from '../../display-objects/DisplayObject';
|
|
2
2
|
import type { ParsedBaseStyleProps } from '../../types';
|
|
3
3
|
export declare const GeometryUpdaterFactory = "GeometryUpdaterFactory";
|
|
4
4
|
export declare const GeometryAABBUpdater = "GeometryAABBGenerator";
|
package/es/shapes/Point.d.ts
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Point } from './Point';
|
|
2
|
+
export declare class PolygonShape {
|
|
3
|
+
points: number[];
|
|
4
|
+
closeStroke: boolean;
|
|
5
|
+
constructor(points: Point[] | number[]);
|
|
6
|
+
constructor(...points: Point[] | number[]);
|
|
7
|
+
clone(): PolygonShape;
|
|
8
|
+
contains(x: number, y: number): boolean;
|
|
9
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
var PolygonShape = function () {
|
|
2
|
+
function PolygonShape() {
|
|
3
|
+
var points = [];
|
|
4
|
+
|
|
5
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
6
|
+
points[_i] = arguments[_i];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
var flat = Array.isArray(points[0]) ? points[0] : points; // if this is an array of points, convert it to a flat array of numbers
|
|
10
|
+
|
|
11
|
+
if (typeof flat[0] !== 'number') {
|
|
12
|
+
var p = [];
|
|
13
|
+
|
|
14
|
+
for (var i = 0, il = flat.length; i < il; i++) {
|
|
15
|
+
p.push(flat[i].x, flat[i].y);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
flat = p;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
this.points = flat;
|
|
22
|
+
/**
|
|
23
|
+
* `false` after moveTo, `true` after `closePath`. In all other cases it is `true`.
|
|
24
|
+
* @member {boolean}
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
this.closeStroke = true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
PolygonShape.prototype.clone = function () {
|
|
32
|
+
var points = this.points.slice();
|
|
33
|
+
var polygon = new PolygonShape(points);
|
|
34
|
+
polygon.closeStroke = this.closeStroke;
|
|
35
|
+
return polygon;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
PolygonShape.prototype.contains = function (x, y) {
|
|
39
|
+
var inside = false; // use some raycasting to test hits
|
|
40
|
+
// https://github.com/substack/point-in-polygon/blob/master/index.js
|
|
41
|
+
|
|
42
|
+
var length = this.points.length / 2;
|
|
43
|
+
|
|
44
|
+
for (var i = 0, j = length - 1; i < length; j = i++) {
|
|
45
|
+
var xi = this.points[i * 2];
|
|
46
|
+
var yi = this.points[i * 2 + 1];
|
|
47
|
+
var xj = this.points[j * 2];
|
|
48
|
+
var yj = this.points[j * 2 + 1];
|
|
49
|
+
var intersect = yi > y !== yj > y && x < (xj - xi) * ((y - yi) / (yj - yi)) + xi;
|
|
50
|
+
|
|
51
|
+
if (intersect) {
|
|
52
|
+
inside = !inside;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return inside;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return PolygonShape;
|
|
60
|
+
}();
|
|
61
|
+
|
|
62
|
+
export { PolygonShape };
|
package/es/shapes/index.d.ts
CHANGED
package/es/shapes/index.js
CHANGED
package/es/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { vec2, vec3 } from 'gl-matrix';
|
|
2
|
-
import type { AbstractRenderer } from './AbstractRenderer';
|
|
3
2
|
import { ParsedPathStyleProps, ParsedPolylineStyleProps } from './display-objects';
|
|
4
|
-
import type { DisplayObject } from './
|
|
3
|
+
import type { DisplayObject } from './display-objects';
|
|
5
4
|
import type { ParsedColorStyleProperty } from './property-handlers';
|
|
5
|
+
import type { IRenderer } from './AbstractRenderer';
|
|
6
6
|
export declare enum SHAPE {
|
|
7
7
|
Group = "group",
|
|
8
8
|
Circle = "circle",
|
|
@@ -20,9 +20,21 @@ declare type ColorType = string | null;
|
|
|
20
20
|
export interface EventPosition {
|
|
21
21
|
clientX: number;
|
|
22
22
|
clientY: number;
|
|
23
|
+
viewportX: number;
|
|
24
|
+
viewportY: number;
|
|
23
25
|
x: number;
|
|
24
26
|
y: number;
|
|
25
27
|
}
|
|
28
|
+
export declare const enum LINE_CAP {
|
|
29
|
+
Butt = "butt",
|
|
30
|
+
Round = "round",
|
|
31
|
+
Square = "square"
|
|
32
|
+
}
|
|
33
|
+
export declare const enum LINE_JOIN {
|
|
34
|
+
Bevel = "bevel",
|
|
35
|
+
Round = "round",
|
|
36
|
+
Miter = "miter"
|
|
37
|
+
}
|
|
26
38
|
export interface BaseStyleProps {
|
|
27
39
|
/**
|
|
28
40
|
* x in local space
|
|
@@ -84,15 +96,15 @@ export interface BaseStyleProps {
|
|
|
84
96
|
opacity?: number;
|
|
85
97
|
/** 线宽 */
|
|
86
98
|
lineWidth?: number;
|
|
87
|
-
lineAppendWidth?: number;
|
|
88
99
|
/** 指定如何绘制每一条线段末端 */
|
|
89
|
-
lineCap?:
|
|
100
|
+
lineCap?: LINE_CAP;
|
|
90
101
|
/** 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性(长度为0的变形部分,其指定的末端和控制点在同一位置,会被忽略) */
|
|
91
|
-
lineJoin?:
|
|
102
|
+
lineJoin?: LINE_JOIN;
|
|
92
103
|
/**
|
|
93
104
|
* 设置线的虚线样式,可以指定一个数组。一组描述交替绘制线段和间距(坐标空间单位)长度的数字。 如果数组元素的数量是奇数, 数组的元素会被复制并重复。例如, [5, 15, 25] 会变成 [5, 15, 25, 5, 15, 25]。这个属性取决于浏览器是否支持 setLineDash() 函数。
|
|
94
105
|
*/
|
|
95
106
|
lineDash?: number[] | null;
|
|
107
|
+
padding?: number[] | number;
|
|
96
108
|
/**
|
|
97
109
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/shadowBlur
|
|
98
110
|
*/
|
|
@@ -151,7 +163,7 @@ export interface CanvasConfig {
|
|
|
151
163
|
/**
|
|
152
164
|
* Renderer
|
|
153
165
|
*/
|
|
154
|
-
renderer:
|
|
166
|
+
renderer: IRenderer;
|
|
155
167
|
/**
|
|
156
168
|
* 容器
|
|
157
169
|
* @type {string|HTMLElement}
|
package/es/utils/animation.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnimationEffectTiming } from '../
|
|
1
|
+
import { AnimationEffectTiming } from '../dom';
|
|
2
2
|
export declare const linear: (x: number) => number;
|
|
3
3
|
export declare function makeTiming(timingInput: KeyframeEffectOptions, forGroup: boolean): AnimationEffectTiming;
|
|
4
4
|
export declare function numericTimingToObject(timingInput: KeyframeEffectOptions | number): KeyframeEffectOptions;
|
|
@@ -16,4 +16,3 @@ export declare const EasingKeys: string[];
|
|
|
16
16
|
* Converts users input into a usable easing function string
|
|
17
17
|
*/
|
|
18
18
|
export declare const getEase: (ease?: keyof typeof EASINGS | string) => string;
|
|
19
|
-
export declare const convertToDash: (str: string) => string;
|
package/es/utils/animation.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __read, __spreadArray } from "tslib";
|
|
2
|
-
import { AnimationEffectTiming } from '../
|
|
3
|
-
import { getEasingFunction } from './custom-easing';
|
|
2
|
+
import { AnimationEffectTiming } from '../dom';
|
|
3
|
+
import { getEasingFunction, convertToDash } from './custom-easing';
|
|
4
4
|
import { bezier } from './bezier-easing';
|
|
5
5
|
var fills = 'backwards|forwards|both|none'.split('|');
|
|
6
6
|
var directions = 'reverse|alternate|alternate-reverse'.split('|');
|
|
@@ -245,7 +245,9 @@ export function calculateIterationProgress(activeDuration, localTime, timing) {
|
|
|
245
245
|
var overallProgress = calculateOverallProgress(duration, phase, timing.iterations, activeTime, timing.iterationStart);
|
|
246
246
|
var simpleIterationProgress = calculateSimpleIterationProgress(overallProgress, timing.iterationStart, phase, timing.iterations, activeTime, duration);
|
|
247
247
|
var currentIteration = calculateCurrentIteration(phase, timing.iterations, simpleIterationProgress, overallProgress);
|
|
248
|
-
var directedProgress = calculateDirectedProgress(timing.direction, currentIteration, simpleIterationProgress);
|
|
248
|
+
var directedProgress = calculateDirectedProgress(timing.direction, currentIteration, simpleIterationProgress);
|
|
249
|
+
timing.currentIteration = currentIteration;
|
|
250
|
+
timing.progress = directedProgress; // https://drafts.csswg.org/web-animations/#calculating-the-transformed-progress
|
|
249
251
|
// https://drafts.csswg.org/web-animations/#calculating-the-iteration-progress
|
|
250
252
|
|
|
251
253
|
return timing.easingFunction(directedProgress);
|
|
@@ -305,11 +307,4 @@ export var getEase = function getEase(ease) {
|
|
|
305
307
|
|
|
306
308
|
var search = convertToDash(ease).replace(/^ease-/, '');
|
|
307
309
|
return EASINGS[search] || ease;
|
|
308
|
-
};
|
|
309
|
-
export var convertToDash = function convertToDash(str) {
|
|
310
|
-
str = str.replace(/([A-Z])/g, function (letter) {
|
|
311
|
-
return "-" + letter.toLowerCase();
|
|
312
|
-
}); // Remove first dash
|
|
313
|
-
|
|
314
|
-
return str.charAt(0) === '-' ? str.substr(1) : str;
|
|
315
310
|
};
|
package/es/utils/canvas.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare const convertToDash: (str: string) => string;
|
|
1
2
|
export declare const limit: (value: number, min: number, max: number) => number;
|
|
2
3
|
/**
|
|
3
4
|
* The format to use when defining custom easing functions
|
|
@@ -69,6 +70,6 @@ export declare const getEasingFunction: (ease: string) => TypeEasingFunction;
|
|
|
69
70
|
*/
|
|
70
71
|
export declare const registerEasingFunction: (key: string, fn: TypeEasingFunction) => void;
|
|
71
72
|
/**
|
|
72
|
-
* Allows you to register multiple new easing functions
|
|
73
|
-
*/
|
|
73
|
+
* Allows you to register multiple new easing functions
|
|
74
|
+
*/
|
|
74
75
|
export declare const registerEasingFunctions: (...obj: Array<typeof EasingFunctions>) => void;
|