@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
|
@@ -7,17 +7,13 @@ var Renderable = function (_super) {
|
|
|
7
7
|
function Renderable() {
|
|
8
8
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
9
9
|
|
|
10
|
-
_this.
|
|
10
|
+
_this.boundsDirty = true;
|
|
11
|
+
_this.renderBoundsDirty = true;
|
|
11
12
|
/**
|
|
12
13
|
* dirty rectangle flag
|
|
13
14
|
*/
|
|
14
15
|
|
|
15
16
|
_this.dirty = false;
|
|
16
|
-
/**
|
|
17
|
-
* is instanced
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
_this.instanced = false;
|
|
21
17
|
return _this;
|
|
22
18
|
}
|
|
23
19
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component } from '@antv/g-ecs';
|
|
2
|
-
import type {
|
|
2
|
+
import type { INode } from '../dom/interfaces';
|
|
3
3
|
export declare class Sortable extends Component {
|
|
4
4
|
static tag: string;
|
|
5
5
|
/**
|
|
@@ -9,5 +9,9 @@ export declare class Sortable extends Component {
|
|
|
9
9
|
/**
|
|
10
10
|
* sorted child entities
|
|
11
11
|
*/
|
|
12
|
-
sorted:
|
|
12
|
+
sorted: INode[];
|
|
13
|
+
/**
|
|
14
|
+
* index in parent's children
|
|
15
|
+
*/
|
|
16
|
+
lastSortedIndex: number;
|
|
13
17
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { DisplayObject } from '
|
|
3
|
-
import { DisplayObjectConfig } from '../DisplayObject';
|
|
1
|
+
import { BaseStyleProps, DisplayObjectConfig, ParsedBaseStyleProps } from '..';
|
|
2
|
+
import { DisplayObject } from './DisplayObject';
|
|
4
3
|
export interface CircleStyleProps extends BaseStyleProps {
|
|
5
4
|
r: number;
|
|
6
5
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __assign, __extends, __rest } from "tslib";
|
|
2
|
-
import { SHAPE } from '
|
|
3
|
-
import { DisplayObject } from '
|
|
2
|
+
import { SHAPE } from '..';
|
|
3
|
+
import { DisplayObject } from './DisplayObject';
|
|
4
4
|
|
|
5
5
|
var Circle = function (_super) {
|
|
6
6
|
__extends(Circle, _super);
|
|
@@ -13,9 +13,6 @@ var Circle = function (_super) {
|
|
|
13
13
|
type: SHAPE.Circle,
|
|
14
14
|
style: __assign({
|
|
15
15
|
r: 0,
|
|
16
|
-
opacity: 1,
|
|
17
|
-
fillOpacity: 1,
|
|
18
|
-
strokeOpacity: 1,
|
|
19
16
|
anchor: [0.5, 0.5]
|
|
20
17
|
}, style)
|
|
21
18
|
}, rest)) || this;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DisplayObjectConfig } from './DisplayObject';
|
|
2
1
|
import { DisplayObject } from './DisplayObject';
|
|
2
|
+
import type { DisplayObjectConfig } from '..';
|
|
3
3
|
export interface CustomElement<CustomElementStyleProps> {
|
|
4
4
|
/**
|
|
5
5
|
* fired after element insert into DOM tree
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __extends } from "tslib";
|
|
2
2
|
import { DisplayObject } from './DisplayObject';
|
|
3
|
-
import {
|
|
3
|
+
import { ElementEvent } from '..';
|
|
4
4
|
/**
|
|
5
5
|
* shadow root
|
|
6
6
|
* @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
|
|
@@ -26,8 +26,8 @@ var CustomElement = function (_super) {
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
_this.handleChildInserted = function (
|
|
30
|
-
|
|
29
|
+
_this.handleChildInserted = function (e) {
|
|
30
|
+
e.target.forEach(function (node) {
|
|
31
31
|
// append children like other shapes after mounted
|
|
32
32
|
if (!_this.isConnected) {
|
|
33
33
|
_this.shadowNodes.push(node);
|
|
@@ -35,30 +35,40 @@ var CustomElement = function (_super) {
|
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
_this.handleChildRemoved = function (
|
|
39
|
-
|
|
38
|
+
_this.handleChildRemoved = function (e) {
|
|
39
|
+
e.target.forEach(function (node) {
|
|
40
40
|
node.shadow = false;
|
|
41
41
|
});
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
_this.handleAttributeChanged = function (
|
|
45
|
-
|
|
44
|
+
_this.handleAttributeChanged = function (e) {
|
|
45
|
+
// only listen itself
|
|
46
|
+
// RangeError: Maximum call stack size exceeded
|
|
47
|
+
if (e.target !== _this) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
var _a = e.detail,
|
|
52
|
+
attributeName = _a.attributeName,
|
|
53
|
+
oldValue = _a.oldValue,
|
|
54
|
+
newValue = _a.newValue;
|
|
55
|
+
_this.attributeChangedCallback && _this.attributeChangedCallback(attributeName, oldValue, newValue);
|
|
46
56
|
};
|
|
47
57
|
|
|
48
|
-
_this.
|
|
58
|
+
_this.addEventListener(ElementEvent.CHILD_INSERTED, _this.handleChildInserted);
|
|
49
59
|
|
|
50
|
-
_this.
|
|
60
|
+
_this.addEventListener(ElementEvent.CHILD_REMOVED, _this.handleChildRemoved);
|
|
51
61
|
|
|
52
62
|
if (_this.attributeChangedCallback) {
|
|
53
|
-
_this.
|
|
63
|
+
_this.addEventListener(ElementEvent.ATTRIBUTE_CHANGED, _this.handleAttributeChanged);
|
|
54
64
|
}
|
|
55
65
|
|
|
56
66
|
if (_this.connectedCallback) {
|
|
57
|
-
_this.
|
|
67
|
+
_this.addEventListener(ElementEvent.INSERTED, _this.handleMounted);
|
|
58
68
|
}
|
|
59
69
|
|
|
60
70
|
if (_this.disconnectedCallback) {
|
|
61
|
-
_this.
|
|
71
|
+
_this.addEventListener(ElementEvent.REMOVED, _this.disconnectedCallback.bind(_this));
|
|
62
72
|
}
|
|
63
73
|
|
|
64
74
|
return _this;
|
|
@@ -1,50 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
export interface DisplayObjectConfig<StyleProps> {
|
|
7
|
-
/**
|
|
8
|
-
* element's identifier, must be unique in a document.
|
|
9
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/id
|
|
10
|
-
*/
|
|
11
|
-
id?: string;
|
|
12
|
-
name?: string;
|
|
13
|
-
className?: string;
|
|
14
|
-
/**
|
|
15
|
-
* all styles properties, not read-only
|
|
16
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style
|
|
17
|
-
*/
|
|
18
|
-
style?: StyleProps;
|
|
19
|
-
/**
|
|
20
|
-
* compatible with G 3.0
|
|
21
|
-
* @alias style
|
|
22
|
-
* @deprecated
|
|
23
|
-
*/
|
|
24
|
-
attrs?: StyleProps;
|
|
25
|
-
type?: SHAPE | string;
|
|
26
|
-
/**
|
|
27
|
-
* @deprecated use `style.zIndex` instead
|
|
28
|
-
*/
|
|
29
|
-
zIndex?: number;
|
|
30
|
-
/**
|
|
31
|
-
* @deprecated use `style.visibility = 'visible'` instead
|
|
32
|
-
*/
|
|
33
|
-
visible?: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* compatible with G 3.0
|
|
36
|
-
* @alias interactive
|
|
37
|
-
* @deprecated
|
|
38
|
-
*/
|
|
39
|
-
capture?: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* enable interaction events for the DisplayObject
|
|
42
|
-
*/
|
|
43
|
-
interactive?: boolean;
|
|
44
|
-
}
|
|
1
|
+
import { mat3, mat4, quat, vec2, vec3 } from 'gl-matrix';
|
|
2
|
+
import { Animation, Element } from '../dom';
|
|
3
|
+
import type { DisplayObjectConfig, INode } from '../dom';
|
|
4
|
+
import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
5
|
+
import { StylePropertyParser, StylePropertyUpdater } from '../property-handlers';
|
|
45
6
|
/**
|
|
46
7
|
* prototype chains: DisplayObject -> Element -> Node -> EventTarget
|
|
47
8
|
*
|
|
9
|
+
* mixins: Animatable, Transformable, Visible
|
|
10
|
+
* @see https://github.com/tannerntannern/ts-mixer/blob/master/README.md#mixing-generic-classes
|
|
11
|
+
*
|
|
48
12
|
* Provide abilities in scene graph, such as:
|
|
49
13
|
* * transform `translate/rotate/scale`
|
|
50
14
|
* * add/remove child
|
|
@@ -58,90 +22,35 @@ export interface DisplayObjectConfig<StyleProps> {
|
|
|
58
22
|
* * attributeChanged
|
|
59
23
|
*/
|
|
60
24
|
export declare class DisplayObject<StyleProps extends BaseStyleProps = any, ParsedStyleProps extends ParsedBaseStyleProps = any> extends Element<StyleProps, ParsedStyleProps> {
|
|
61
|
-
protected config: DisplayObjectConfig<StyleProps>;
|
|
62
|
-
shadow: boolean;
|
|
63
|
-
private displayObjectPool;
|
|
64
|
-
private stylePropertyUpdaterFactory;
|
|
65
|
-
private stylePropertyParserFactory;
|
|
66
|
-
constructor(config: DisplayObjectConfig<StyleProps>);
|
|
67
25
|
/**
|
|
68
|
-
*
|
|
69
|
-
* @deprecated
|
|
26
|
+
* contains style props in constructor's params, eg. fill, stroke...
|
|
70
27
|
*/
|
|
71
|
-
|
|
72
|
-
get(name: keyof DisplayObjectConfig<StyleProps>): string | number | boolean | StyleProps;
|
|
73
|
-
getConfig(): DisplayObjectConfig<StyleProps>;
|
|
74
|
-
/**
|
|
75
|
-
* @deprecated
|
|
76
|
-
*/
|
|
77
|
-
attr(): StyleProps;
|
|
78
|
-
attr(name: Partial<StyleProps>): DisplayObject<StyleProps>;
|
|
79
|
-
attr<Key extends keyof StyleProps>(name: Key): StyleProps[Key];
|
|
80
|
-
attr<Key extends keyof StyleProps>(name: Key, value: StyleProps[Key]): DisplayObject<StyleProps>;
|
|
81
|
-
/** scene graph operations */
|
|
82
|
-
scrollLeft: number;
|
|
83
|
-
scrollTop: number;
|
|
28
|
+
config: DisplayObjectConfig<StyleProps>;
|
|
84
29
|
/**
|
|
85
|
-
*
|
|
30
|
+
* push to active animations after calling `animate()`
|
|
86
31
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
* @deprecated
|
|
96
|
-
* compatible with G 3.0
|
|
97
|
-
* @deprecated
|
|
98
|
-
*/
|
|
99
|
-
getParent(): this | null;
|
|
100
|
-
/**
|
|
101
|
-
* @deprecated
|
|
102
|
-
* compatible with G 3.0
|
|
103
|
-
* @deprecated
|
|
104
|
-
*/
|
|
105
|
-
getChildren(): this[];
|
|
106
|
-
/**
|
|
107
|
-
* @deprecated
|
|
108
|
-
* compatible with G 3.0
|
|
109
|
-
* @deprecated
|
|
110
|
-
*/
|
|
111
|
-
getFirst(): this | null;
|
|
112
|
-
/**
|
|
113
|
-
* @deprecated
|
|
114
|
-
* compatible with G 3.0
|
|
115
|
-
* @deprecated
|
|
116
|
-
* get last child group/shape
|
|
117
|
-
*/
|
|
118
|
-
getLast(): this | null;
|
|
32
|
+
private activeAnimations;
|
|
33
|
+
stylePropertyUpdaterFactory: <Key extends keyof StyleProps>(stylePropertyName: Key) => StylePropertyUpdater<any>[];
|
|
34
|
+
stylePropertyParserFactory: <Key extends keyof ParsedStyleProps>(stylePropertyName: Key) => StylePropertyParser<any, any>;
|
|
35
|
+
constructor(config: DisplayObjectConfig<StyleProps>);
|
|
36
|
+
destroy(): void;
|
|
37
|
+
cloneNode(deep?: boolean): this;
|
|
38
|
+
private initAttributes;
|
|
39
|
+
setAttribute<Key extends keyof StyleProps>(attributeName: Key, value: StyleProps[Key], force?: boolean): void;
|
|
119
40
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* get child group/shape by index
|
|
41
|
+
* parse property, eg.
|
|
42
|
+
* * fill: 'red' => [1, 0, 0, 1]
|
|
43
|
+
* * translateX: '10px' => { unit: 'px', value: 10 }
|
|
124
44
|
*/
|
|
125
|
-
|
|
45
|
+
private parseStyleProperty;
|
|
46
|
+
private updateStyleProperty;
|
|
126
47
|
/**
|
|
127
|
-
*
|
|
128
|
-
* @deprecated
|
|
48
|
+
* called when attributes get changed or initialized
|
|
129
49
|
*/
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
setOrigin(position: vec3 | number, y?: number, z?: number): this;
|
|
50
|
+
private changeAttribute;
|
|
51
|
+
setOrigin(position: vec3 | vec2 | number, y?: number, z?: number): this;
|
|
133
52
|
getOrigin(): vec3;
|
|
134
53
|
/**
|
|
135
|
-
* alias setPosition
|
|
136
|
-
*/
|
|
137
|
-
moveTo(position: vec3 | vec2 | number, y?: number, z?: number): this;
|
|
138
|
-
/**
|
|
139
|
-
* alias setPosition
|
|
140
|
-
*/
|
|
141
|
-
move(position: vec3 | vec2 | number, y?: number, z?: number): this;
|
|
142
|
-
/**
|
|
143
|
-
* compatible with G 3.0
|
|
144
|
-
*
|
|
145
54
|
* set position in world space
|
|
146
55
|
*/
|
|
147
56
|
setPosition(position: vec3 | vec2 | number, y?: number, z?: number): this;
|
|
@@ -203,25 +112,24 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
|
|
|
203
112
|
getLocalRotation(): quat;
|
|
204
113
|
getLocalTransform(): mat4;
|
|
205
114
|
getWorldTransform(): mat4;
|
|
115
|
+
resetLocalTransform(): void;
|
|
206
116
|
/**
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* set 3x3 matrix in world space
|
|
213
|
-
* @deprecated
|
|
117
|
+
* sync style.x/y when local position changed
|
|
118
|
+
*
|
|
119
|
+
* Mixins may not declare private/protected properties
|
|
120
|
+
* however, you can use ES2020 private fields
|
|
214
121
|
*/
|
|
215
|
-
|
|
216
|
-
setZIndex(zIndex: number): void;
|
|
122
|
+
private syncLocalPosition;
|
|
217
123
|
/**
|
|
218
|
-
*
|
|
124
|
+
* returns an array of all Animation objects affecting this element
|
|
125
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAnimations
|
|
219
126
|
*/
|
|
220
|
-
|
|
127
|
+
getAnimations(): Animation[];
|
|
221
128
|
/**
|
|
222
|
-
*
|
|
129
|
+
* create an animation with WAAPI
|
|
130
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/animate
|
|
223
131
|
*/
|
|
224
|
-
|
|
132
|
+
animate(keyframes: Keyframe[] | PropertyIndexedKeyframes | null, options?: number | KeyframeAnimationOptions | undefined): Animation | null;
|
|
225
133
|
/**
|
|
226
134
|
* show group, which will also change visibility of its children in sceneGraphNode
|
|
227
135
|
*
|
|
@@ -233,6 +141,57 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
|
|
|
233
141
|
*/
|
|
234
142
|
hide(): void;
|
|
235
143
|
isVisible(): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* bring to front in current group
|
|
146
|
+
*/
|
|
147
|
+
toFront(): this;
|
|
148
|
+
/**
|
|
149
|
+
* send to back in current group
|
|
150
|
+
*/
|
|
151
|
+
toBack(): this;
|
|
152
|
+
/**
|
|
153
|
+
* @deprecated
|
|
154
|
+
* compatible with G 3.0
|
|
155
|
+
* @deprecated
|
|
156
|
+
*/
|
|
157
|
+
getCount(): number;
|
|
158
|
+
/**
|
|
159
|
+
* @deprecated
|
|
160
|
+
* compatible with G 3.0
|
|
161
|
+
* @deprecated
|
|
162
|
+
*/
|
|
163
|
+
getParent(): DisplayObject | null;
|
|
164
|
+
/**
|
|
165
|
+
* @deprecated
|
|
166
|
+
* compatible with G 3.0
|
|
167
|
+
* @deprecated
|
|
168
|
+
*/
|
|
169
|
+
getChildren(): DisplayObject[];
|
|
170
|
+
/**
|
|
171
|
+
* @deprecated
|
|
172
|
+
* compatible with G 3.0
|
|
173
|
+
* @deprecated
|
|
174
|
+
*/
|
|
175
|
+
getFirst(): DisplayObject | null;
|
|
176
|
+
/**
|
|
177
|
+
* @deprecated
|
|
178
|
+
* compatible with G 3.0
|
|
179
|
+
* @deprecated
|
|
180
|
+
* get last child group/shape
|
|
181
|
+
*/
|
|
182
|
+
getLast(): DisplayObject | null;
|
|
183
|
+
/**
|
|
184
|
+
* @deprecated
|
|
185
|
+
* compatible with G 3.0
|
|
186
|
+
* @deprecated
|
|
187
|
+
* get child group/shape by index
|
|
188
|
+
*/
|
|
189
|
+
getChildByIndex(index: number): DisplayObject | null;
|
|
190
|
+
/**
|
|
191
|
+
* compatible with G 3.0
|
|
192
|
+
* @deprecated
|
|
193
|
+
*/
|
|
194
|
+
add<T extends INode>(child: T, index?: number): T;
|
|
236
195
|
/**
|
|
237
196
|
* @alias style.clipPath
|
|
238
197
|
* @deprecated
|
|
@@ -244,19 +203,55 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
|
|
|
244
203
|
*/
|
|
245
204
|
getClip(): DisplayObject<any, any>;
|
|
246
205
|
/**
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
* * translateX: '10px' => { unit: 'px', value: 10 }
|
|
206
|
+
* compatible with G 3.0
|
|
207
|
+
* @deprecated
|
|
250
208
|
*/
|
|
251
|
-
|
|
252
|
-
private updateStyleProperty;
|
|
209
|
+
set<Key extends keyof DisplayObjectConfig<StyleProps>>(name: Key, value: DisplayObjectConfig<StyleProps>[Key]): void;
|
|
253
210
|
/**
|
|
254
|
-
*
|
|
211
|
+
* compatible with G 3.0
|
|
212
|
+
* @deprecated
|
|
255
213
|
*/
|
|
256
|
-
|
|
257
|
-
private initAttributes;
|
|
214
|
+
get(name: keyof DisplayObjectConfig<StyleProps>): string | number | boolean | StyleProps;
|
|
258
215
|
/**
|
|
259
|
-
*
|
|
216
|
+
* compatible with G 3.0
|
|
217
|
+
* @alias object.config
|
|
218
|
+
* @deprecated
|
|
260
219
|
*/
|
|
261
|
-
|
|
220
|
+
getConfig(): DisplayObjectConfig<StyleProps>;
|
|
221
|
+
/**
|
|
222
|
+
* @alias style
|
|
223
|
+
* @example
|
|
224
|
+
* circle.style.r = 10;
|
|
225
|
+
* const r = circle.style;
|
|
226
|
+
* @deprecated
|
|
227
|
+
*/
|
|
228
|
+
attr(): StyleProps;
|
|
229
|
+
attr(name: Partial<StyleProps>): DisplayObject<StyleProps>;
|
|
230
|
+
attr<Key extends keyof StyleProps>(name: Key): StyleProps[Key];
|
|
231
|
+
attr<Key extends keyof StyleProps>(name: Key, value: StyleProps[Key]): DisplayObject<StyleProps>;
|
|
232
|
+
/**
|
|
233
|
+
* @alias setPosition
|
|
234
|
+
* @deprecated
|
|
235
|
+
*/
|
|
236
|
+
moveTo(position: vec3 | vec2 | number, y?: number, z?: number): this;
|
|
237
|
+
/**
|
|
238
|
+
* @alias setPosition
|
|
239
|
+
* @deprecated
|
|
240
|
+
*/
|
|
241
|
+
move(position: vec3 | vec2 | number, y?: number, z?: number): this;
|
|
242
|
+
/**
|
|
243
|
+
* @alias style.zIndex
|
|
244
|
+
* @deprecated
|
|
245
|
+
*/
|
|
246
|
+
setZIndex(zIndex: number): this;
|
|
247
|
+
/**
|
|
248
|
+
* return 3x3 matrix in world space
|
|
249
|
+
* @deprecated
|
|
250
|
+
*/
|
|
251
|
+
getMatrix(): mat3;
|
|
252
|
+
/**
|
|
253
|
+
* set 3x3 matrix in world space
|
|
254
|
+
* @deprecated
|
|
255
|
+
*/
|
|
256
|
+
setMatrix(mat: mat3): void;
|
|
262
257
|
}
|