@antv/g 5.0.14 → 5.0.17
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/AbstractRenderer.js +1 -3
- package/es/Canvas.d.ts +3 -0
- package/es/Canvas.js +10 -12
- package/es/DisplayObjectPool.js +1 -3
- package/es/camera/Camera.d.ts +3 -2
- package/es/camera/Camera.js +17 -11
- package/es/camera/Landmark.js +1 -3
- package/es/canvas-module.js +11 -17
- package/es/components/Cullable.js +1 -3
- package/es/components/Geometry.js +1 -3
- package/es/components/Renderable.js +1 -3
- package/es/components/Sortable.js +1 -3
- package/es/components/Transform.d.ts +0 -1
- package/es/components/Transform.js +1 -4
- package/es/display-objects/Circle.d.ts +4 -2
- package/es/display-objects/Circle.js +9 -6
- package/es/display-objects/CustomElement.d.ts +3 -2
- package/es/display-objects/CustomElement.js +10 -9
- package/es/display-objects/DisplayObject.d.ts +9 -3
- package/es/display-objects/DisplayObject.js +98 -50
- package/es/display-objects/Ellipse.d.ts +6 -3
- package/es/display-objects/Ellipse.js +9 -6
- package/es/display-objects/Group.d.ts +18 -2
- package/es/display-objects/Group.js +15 -12
- package/es/display-objects/HTML.d.ts +6 -1
- package/es/display-objects/HTML.js +8 -6
- package/es/display-objects/Image.d.ts +12 -7
- package/es/display-objects/Image.js +11 -6
- package/es/display-objects/Line.d.ts +1 -1
- package/es/display-objects/Line.js +13 -7
- package/es/display-objects/Path.d.ts +3 -2
- package/es/display-objects/Path.js +11 -8
- package/es/display-objects/Polygon.d.ts +1 -1
- package/es/display-objects/Polygon.js +10 -6
- package/es/display-objects/Polyline.d.ts +1 -1
- package/es/display-objects/Polyline.js +11 -8
- package/es/display-objects/Rect.d.ts +8 -5
- package/es/display-objects/Rect.js +10 -7
- package/es/display-objects/TSpan.d.ts +1 -0
- package/es/display-objects/TSpan.js +0 -0
- package/es/display-objects/Text.d.ts +32 -4
- package/es/display-objects/Text.js +71 -14
- package/es/dom/Animation.js +2 -4
- package/es/dom/AnimationEffectTiming.js +1 -3
- package/es/dom/AnimationEvent.js +1 -3
- package/es/dom/AnimationTimeline.js +2 -5
- package/es/dom/CustomElementRegistry.js +13 -15
- package/es/dom/CustomEvent.js +1 -3
- package/es/dom/Document.d.ts +2 -1
- package/es/dom/Document.js +23 -5
- package/es/dom/Element.d.ts +36 -9
- package/es/dom/Element.js +103 -15
- package/es/dom/EventTarget.d.ts +2 -2
- package/es/dom/EventTarget.js +3 -4
- package/es/dom/FederatedEvent.d.ts +5 -2
- package/es/dom/FederatedEvent.js +1 -3
- package/es/dom/FederatedMouseEvent.js +1 -3
- package/es/dom/FederatedPointerEvent.js +1 -3
- package/es/dom/FederatedWheelEvent.js +1 -3
- package/es/dom/KeyframeEffect.js +1 -3
- package/es/dom/MutationEvent.d.ts +15 -0
- package/es/dom/MutationEvent.js +27 -0
- package/es/dom/MutationObserver.d.ts +36 -0
- package/es/dom/MutationObserver.js +406 -0
- package/es/dom/MutationRecord.d.ts +14 -0
- package/es/dom/MutationRecord.js +29 -0
- package/es/dom/Node.d.ts +35 -3
- package/es/dom/Node.js +185 -20
- package/es/dom/index.d.ts +3 -0
- package/es/dom/index.js +3 -0
- package/es/dom/interfaces.d.ts +36 -8
- package/es/dom/interfaces.js +23 -5
- package/es/global-module.d.ts +4 -1
- package/es/global-module.js +36 -79
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/plugins/CullingPlugin.d.ts +0 -2
- package/es/plugins/CullingPlugin.js +4 -27
- package/es/plugins/DirtyCheckPlugin.js +3 -5
- package/es/plugins/EventPlugin.d.ts +2 -1
- package/es/plugins/EventPlugin.js +16 -8
- package/es/plugins/FrustumCullingStrategy.d.ts +1 -0
- package/es/plugins/FrustumCullingStrategy.js +40 -35
- package/es/plugins/PrepareRendererPlugin.js +22 -8
- package/es/property-handlers/aabb.js +22 -24
- package/es/property-handlers/anchor.js +2 -1
- package/es/property-handlers/color.js +3 -0
- package/es/property-handlers/dimension.d.ts +15 -2
- package/es/property-handlers/dimension.js +77 -8
- package/es/property-handlers/index.d.ts +3 -0
- package/es/property-handlers/index.js +4 -1
- package/es/property-handlers/inherit.d.ts +6 -0
- package/es/property-handlers/inherit.js +25 -0
- package/es/property-handlers/interfaces.d.ts +2 -2
- package/es/property-handlers/lineDash.d.ts +6 -1
- package/es/property-handlers/lineDash.js +23 -4
- package/es/property-handlers/offsetDistance.js +2 -2
- package/es/property-handlers/path.d.ts +1 -1
- package/es/property-handlers/text.d.ts +2 -0
- package/es/property-handlers/text.js +3 -0
- package/es/property-handlers/textTransform.d.ts +6 -0
- package/es/property-handlers/textTransform.js +19 -0
- package/es/services/EventService.js +2 -6
- package/es/services/RenderingContext.d.ts +5 -8
- package/es/services/RenderingContext.js +6 -7
- package/es/services/RenderingService.js +3 -11
- package/es/services/SceneGraphSelector.d.ts +3 -2
- package/es/services/SceneGraphSelector.js +9 -7
- package/es/services/SceneGraphService.d.ts +7 -14
- package/es/services/SceneGraphService.js +15 -85
- package/es/services/aabb/CircleUpdater.d.ts +2 -2
- package/es/services/aabb/CircleUpdater.js +22 -14
- package/es/services/aabb/EllipseUpdater.d.ts +2 -2
- package/es/services/aabb/EllipseUpdater.js +29 -16
- package/es/services/aabb/LineUpdater.js +3 -5
- package/es/services/aabb/PathUpdater.js +3 -5
- package/es/services/aabb/PolylineUpdater.js +4 -6
- package/es/services/aabb/RectUpdater.d.ts +2 -2
- package/es/services/aabb/RectUpdater.js +32 -21
- package/es/services/aabb/TextUpdater.js +20 -13
- package/es/services/text/OffscreenCanvasCreator.js +1 -3
- package/es/services/text/index.js +18 -22
- package/es/shapes/AABB.d.ts +1 -0
- package/es/shapes/AABB.js +9 -3
- package/es/shapes/BoundingSphere.js +1 -3
- package/es/shapes/Frustum.js +1 -3
- package/es/shapes/Plane.js +1 -3
- package/es/shapes/Point.js +1 -3
- package/es/shapes/Polygon.js +1 -3
- package/es/shapes/Ray.js +1 -3
- package/es/shapes/Rect.js +1 -3
- package/es/shapes/Rectangle.js +1 -3
- package/es/types.d.ts +48 -26
- package/es/types.js +50 -31
- package/es/utils/animation.js +1 -1
- package/es/utils/event.js +5 -3
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +2 -1
- package/es/utils/interpolation.d.ts +1 -0
- package/es/utils/interpolation.js +41 -8
- package/es/utils/path.d.ts +1 -1
- package/es/utils/path.js +13 -13
- package/es/utils/raf.d.ts +1 -1
- package/es/utils/raf.js +0 -2
- package/es/utils/string.d.ts +1 -0
- package/es/utils/string.js +9 -0
- package/es/utils/text.js +1 -1
- package/lib/AbstractRenderer.js +1 -3
- package/lib/Canvas.d.ts +3 -0
- package/lib/Canvas.js +9 -11
- package/lib/DisplayObjectPool.js +1 -3
- package/lib/camera/Camera.d.ts +3 -2
- package/lib/camera/Camera.js +21 -13
- package/lib/camera/Landmark.js +1 -3
- package/lib/canvas-module.js +10 -15
- package/lib/components/Cullable.js +2 -4
- package/lib/components/Geometry.js +1 -3
- package/lib/components/Renderable.js +1 -3
- package/lib/components/Sortable.js +1 -3
- package/lib/components/Transform.d.ts +0 -1
- package/lib/components/Transform.js +1 -4
- package/lib/display-objects/Circle.d.ts +4 -2
- package/lib/display-objects/Circle.js +8 -5
- package/lib/display-objects/CustomElement.d.ts +3 -2
- package/lib/display-objects/CustomElement.js +10 -9
- package/lib/display-objects/DisplayObject.d.ts +9 -3
- package/lib/display-objects/DisplayObject.js +98 -47
- package/lib/display-objects/Ellipse.d.ts +6 -3
- package/lib/display-objects/Ellipse.js +8 -5
- package/lib/display-objects/Group.d.ts +18 -2
- package/lib/display-objects/Group.js +14 -12
- package/lib/display-objects/HTML.d.ts +6 -1
- package/lib/display-objects/HTML.js +7 -5
- package/lib/display-objects/Image.d.ts +12 -7
- package/lib/display-objects/Image.js +10 -5
- package/lib/display-objects/Line.d.ts +1 -1
- package/lib/display-objects/Line.js +12 -6
- package/lib/display-objects/Path.d.ts +3 -2
- package/lib/display-objects/Path.js +10 -7
- package/lib/display-objects/Polygon.d.ts +1 -1
- package/lib/display-objects/Polygon.js +9 -5
- package/lib/display-objects/Polyline.d.ts +1 -1
- package/lib/display-objects/Polyline.js +10 -7
- package/lib/display-objects/Rect.d.ts +8 -5
- package/lib/display-objects/Rect.js +9 -6
- package/lib/display-objects/TSpan.d.ts +1 -0
- package/lib/display-objects/TSpan.js +1 -0
- package/lib/display-objects/Text.d.ts +32 -4
- package/lib/display-objects/Text.js +71 -13
- package/lib/dom/Animation.js +2 -4
- package/lib/dom/AnimationEffectTiming.js +1 -3
- package/lib/dom/AnimationEvent.js +1 -3
- package/lib/dom/AnimationTimeline.js +3 -6
- package/lib/dom/CustomElementRegistry.js +12 -14
- package/lib/dom/CustomEvent.js +1 -3
- package/lib/dom/Document.d.ts +2 -1
- package/lib/dom/Document.js +25 -6
- package/lib/dom/Element.d.ts +36 -9
- package/lib/dom/Element.js +105 -15
- package/lib/dom/EventTarget.d.ts +2 -2
- package/lib/dom/EventTarget.js +3 -4
- package/lib/dom/FederatedEvent.d.ts +5 -2
- package/lib/dom/FederatedEvent.js +1 -3
- package/lib/dom/FederatedMouseEvent.js +1 -3
- package/lib/dom/FederatedPointerEvent.js +1 -3
- package/lib/dom/FederatedWheelEvent.js +1 -3
- package/lib/dom/KeyframeEffect.js +2 -4
- package/lib/dom/MutationEvent.d.ts +15 -0
- package/lib/dom/MutationEvent.js +35 -0
- package/lib/dom/MutationObserver.d.ts +36 -0
- package/lib/dom/MutationObserver.js +417 -0
- package/lib/dom/MutationRecord.d.ts +14 -0
- package/lib/dom/MutationRecord.js +36 -0
- package/lib/dom/Node.d.ts +35 -3
- package/lib/dom/Node.js +186 -19
- package/lib/dom/index.d.ts +3 -0
- package/lib/dom/index.js +39 -0
- package/lib/dom/interfaces.d.ts +36 -8
- package/lib/dom/interfaces.js +23 -5
- package/lib/global-module.d.ts +4 -1
- package/lib/global-module.js +42 -76
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -0
- package/lib/plugins/CullingPlugin.d.ts +0 -2
- package/lib/plugins/CullingPlugin.js +4 -27
- package/lib/plugins/DirtyCheckPlugin.js +2 -4
- package/lib/plugins/EventPlugin.d.ts +2 -1
- package/lib/plugins/EventPlugin.js +14 -8
- package/lib/plugins/FrustumCullingStrategy.d.ts +1 -0
- package/lib/plugins/FrustumCullingStrategy.js +41 -35
- package/lib/plugins/PrepareRendererPlugin.js +25 -7
- package/lib/property-handlers/aabb.js +21 -23
- package/lib/property-handlers/anchor.js +3 -1
- package/lib/property-handlers/color.js +5 -2
- package/lib/property-handlers/dimension.d.ts +15 -2
- package/lib/property-handlers/dimension.js +84 -12
- package/lib/property-handlers/index.d.ts +3 -0
- package/lib/property-handlers/index.js +39 -0
- package/lib/property-handlers/inherit.d.ts +6 -0
- package/lib/property-handlers/inherit.js +34 -0
- package/lib/property-handlers/interfaces.d.ts +2 -2
- package/lib/property-handlers/interfaces.js +1 -1
- package/lib/property-handlers/lineDash.d.ts +6 -1
- package/lib/property-handlers/lineDash.js +25 -4
- package/lib/property-handlers/numeric.js +3 -3
- package/lib/property-handlers/offsetDistance.js +1 -1
- package/lib/property-handlers/path.d.ts +1 -1
- package/lib/property-handlers/path.js +1 -1
- package/lib/property-handlers/text.d.ts +2 -0
- package/lib/property-handlers/text.js +10 -0
- package/lib/property-handlers/textTransform.d.ts +6 -0
- package/lib/property-handlers/textTransform.js +27 -0
- package/lib/property-handlers/transform.js +1 -1
- package/lib/services/EventService.js +2 -6
- package/lib/services/RenderingContext.d.ts +5 -8
- package/lib/services/RenderingContext.js +8 -9
- package/lib/services/RenderingService.js +2 -10
- package/lib/services/SceneGraphSelector.d.ts +3 -2
- package/lib/services/SceneGraphSelector.js +12 -7
- package/lib/services/SceneGraphService.d.ts +7 -14
- package/lib/services/SceneGraphService.js +18 -87
- package/lib/services/aabb/CircleUpdater.d.ts +2 -2
- package/lib/services/aabb/CircleUpdater.js +21 -13
- package/lib/services/aabb/EllipseUpdater.d.ts +2 -2
- package/lib/services/aabb/EllipseUpdater.js +28 -15
- package/lib/services/aabb/LineUpdater.js +2 -4
- package/lib/services/aabb/PathUpdater.js +2 -4
- package/lib/services/aabb/PolylineUpdater.js +3 -5
- package/lib/services/aabb/RectUpdater.d.ts +2 -2
- package/lib/services/aabb/RectUpdater.js +31 -20
- package/lib/services/aabb/TextUpdater.js +19 -12
- package/lib/services/aabb/index.js +10 -10
- package/lib/services/aabb/interfaces.js +1 -1
- package/lib/services/text/OffscreenCanvasCreator.js +1 -3
- package/lib/services/text/index.js +18 -22
- package/lib/shapes/AABB.d.ts +1 -0
- package/lib/shapes/AABB.js +9 -3
- package/lib/shapes/BoundingSphere.js +1 -3
- package/lib/shapes/Frustum.js +2 -4
- package/lib/shapes/Plane.js +1 -3
- package/lib/shapes/Point.js +1 -3
- package/lib/shapes/Polygon.js +1 -3
- package/lib/shapes/Ray.js +1 -3
- package/lib/shapes/Rect.js +1 -3
- package/lib/shapes/Rectangle.js +1 -3
- package/lib/types.d.ts +48 -26
- package/lib/types.js +56 -35
- package/lib/utils/animation.js +3 -4
- package/lib/utils/bezier-easing.js +1 -1
- package/lib/utils/custom-easing.js +1 -1
- package/lib/utils/event.js +7 -6
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +13 -0
- package/lib/utils/interpolation.d.ts +1 -0
- package/lib/utils/interpolation.js +43 -7
- package/lib/utils/math.js +5 -5
- package/lib/utils/path.d.ts +1 -1
- package/lib/utils/path.js +15 -15
- package/lib/utils/raf.d.ts +1 -1
- package/lib/utils/raf.js +1 -4
- package/lib/utils/string.d.ts +1 -0
- package/lib/utils/string.js +16 -0
- package/lib/utils/text.js +1 -1
- package/package.json +6 -4
- package/dist/index.umd.min.js +0 -15
|
@@ -10,14 +10,11 @@ var _glMatrix = require("gl-matrix");
|
|
|
10
10
|
/**
|
|
11
11
|
* do RTS transformation for 2D/3D
|
|
12
12
|
*/
|
|
13
|
-
var Transform =
|
|
14
|
-
/** @class */
|
|
15
|
-
function () {
|
|
13
|
+
var Transform = function () {
|
|
16
14
|
function Transform() {
|
|
17
15
|
this.dirtyFlag = false;
|
|
18
16
|
this.localDirtyFlag = false;
|
|
19
17
|
this.frozen = false;
|
|
20
|
-
this.graphDepth = 0;
|
|
21
18
|
/**
|
|
22
19
|
* local space RTS
|
|
23
20
|
*/
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { DisplayObjectConfig } from '../dom/interfaces';
|
|
2
2
|
import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
3
3
|
import { DisplayObject } from './DisplayObject';
|
|
4
|
+
import type { ParsedElement } from '../property-handlers';
|
|
4
5
|
export interface CircleStyleProps extends BaseStyleProps {
|
|
5
6
|
r: number;
|
|
6
7
|
}
|
|
7
8
|
export interface ParsedCircleStyleProps extends ParsedBaseStyleProps {
|
|
8
|
-
r:
|
|
9
|
+
r: ParsedElement;
|
|
10
|
+
rInPixels: number;
|
|
9
11
|
}
|
|
10
12
|
export declare class Circle extends DisplayObject<CircleStyleProps, ParsedCircleStyleProps> {
|
|
11
|
-
constructor({ style, ...rest }
|
|
13
|
+
constructor({ style, ...rest }?: DisplayObjectConfig<CircleStyleProps>);
|
|
12
14
|
}
|
|
@@ -11,19 +11,22 @@ var _types = require("../types");
|
|
|
11
11
|
|
|
12
12
|
var _DisplayObject = require("./DisplayObject");
|
|
13
13
|
|
|
14
|
-
var Circle =
|
|
15
|
-
/** @class */
|
|
16
|
-
function (_super) {
|
|
14
|
+
var Circle = function (_super) {
|
|
17
15
|
(0, _tslib.__extends)(Circle, _super);
|
|
18
16
|
|
|
19
17
|
function Circle(_a) {
|
|
18
|
+
if (_a === void 0) {
|
|
19
|
+
_a = {};
|
|
20
|
+
}
|
|
21
|
+
|
|
20
22
|
var style = _a.style,
|
|
21
23
|
rest = (0, _tslib.__rest)(_a, ["style"]);
|
|
22
24
|
return _super.call(this, (0, _tslib.__assign)({
|
|
23
|
-
type: _types.
|
|
25
|
+
type: _types.Shape.CIRCLE,
|
|
24
26
|
style: (0, _tslib.__assign)({
|
|
25
27
|
r: 0,
|
|
26
|
-
anchor: [0.5, 0.5]
|
|
28
|
+
anchor: [0.5, 0.5],
|
|
29
|
+
lineWidth: 0
|
|
27
30
|
}, style)
|
|
28
31
|
}, rest)) || this;
|
|
29
32
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { DisplayObject } from './DisplayObject';
|
|
2
2
|
import type { DisplayObjectConfig } from '../dom/interfaces';
|
|
3
|
+
import type { BaseStyleProps } from '../types';
|
|
3
4
|
/**
|
|
4
5
|
* shadow root
|
|
5
6
|
* @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
|
|
6
7
|
*/
|
|
7
|
-
export declare abstract class CustomElement<CustomElementStyleProps> extends DisplayObject<CustomElementStyleProps> {
|
|
8
|
-
constructor(config
|
|
8
|
+
export declare abstract class CustomElement<CustomElementStyleProps extends BaseStyleProps> extends DisplayObject<CustomElementStyleProps> {
|
|
9
|
+
constructor(config?: DisplayObjectConfig<CustomElementStyleProps>);
|
|
9
10
|
/**
|
|
10
11
|
* fired after element insert into DOM tree
|
|
11
12
|
*/
|
|
@@ -15,12 +15,14 @@ var _interfaces = require("../dom/interfaces");
|
|
|
15
15
|
* shadow root
|
|
16
16
|
* @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
|
|
17
17
|
*/
|
|
18
|
-
var CustomElement =
|
|
19
|
-
/** @class */
|
|
20
|
-
function (_super) {
|
|
18
|
+
var CustomElement = function (_super) {
|
|
21
19
|
(0, _tslib.__extends)(CustomElement, _super); // private shadowNodes: DisplayObject[] = [];
|
|
22
20
|
|
|
23
21
|
function CustomElement(config) {
|
|
22
|
+
if (config === void 0) {
|
|
23
|
+
config = {};
|
|
24
|
+
}
|
|
25
|
+
|
|
24
26
|
var _this = _super.call(this, config) || this;
|
|
25
27
|
|
|
26
28
|
_this.handleMounted = function (e) {
|
|
@@ -64,20 +66,19 @@ function (_super) {
|
|
|
64
66
|
return;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
var
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
newValue = _a.newValue;
|
|
69
|
+
var attrName = e.attrName,
|
|
70
|
+
prevValue = e.prevValue,
|
|
71
|
+
newValue = e.newValue;
|
|
71
72
|
|
|
72
73
|
if (_this.attributeChangedCallback) {
|
|
73
|
-
_this.attributeChangedCallback(
|
|
74
|
+
_this.attributeChangedCallback(attrName, prevValue, newValue);
|
|
74
75
|
}
|
|
75
76
|
}; // this.addEventListener(ElementEvent.CHILD_INSERTED, this.handleChildInserted);
|
|
76
77
|
// this.addEventListener(ElementEvent.CHILD_REMOVED, this.handleChildRemoved);
|
|
77
78
|
|
|
78
79
|
|
|
79
80
|
if (_this.attributeChangedCallback) {
|
|
80
|
-
_this.addEventListener(_interfaces.ElementEvent.
|
|
81
|
+
_this.addEventListener(_interfaces.ElementEvent.ATTR_MODIFIED, _this.handleAttributeChanged);
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
if (_this.connectedCallback) {
|
|
@@ -35,18 +35,24 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
|
|
|
35
35
|
destroy(): void;
|
|
36
36
|
cloneNode(deep?: boolean): this;
|
|
37
37
|
private initAttributes;
|
|
38
|
-
setAttribute<Key extends keyof StyleProps>(
|
|
38
|
+
setAttribute<Key extends keyof StyleProps>(name: Key, value: StyleProps[Key], force?: boolean): void;
|
|
39
39
|
/**
|
|
40
40
|
* parse property, eg.
|
|
41
41
|
* * fill: 'red' => [1, 0, 0, 1]
|
|
42
42
|
* * translateX: '10px' => { unit: 'px', value: 10 }
|
|
43
|
+
* * fontSize: '2em' => { unit: 'px', value: 32 }
|
|
43
44
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
parseStyleProperty<Key extends keyof ParsedStyleProps>(name: Key, value: ParsedStyleProps[Key]): void;
|
|
46
|
+
updateStyleProperty<Key extends keyof ParsedStyleProps>(name: Key, oldParsedValue: ParsedStyleProps[Key], newParsedValue: ParsedStyleProps[Key]): void;
|
|
46
47
|
/**
|
|
47
48
|
* called when attributes get changed or initialized
|
|
48
49
|
*/
|
|
49
50
|
private changeAttribute;
|
|
51
|
+
/**
|
|
52
|
+
* returns different values than getBoundingClientRect(), as the latter returns value relative to the viewport
|
|
53
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/SVGGraphicsElement/getBBox
|
|
54
|
+
*/
|
|
55
|
+
getBBox(): DOMRect;
|
|
50
56
|
setOrigin(position: vec3 | vec2 | number, y?: number, z?: number): this;
|
|
51
57
|
getOrigin(): vec3;
|
|
52
58
|
/**
|
|
@@ -27,8 +27,10 @@ var _globalModule = require("../global-module");
|
|
|
27
27
|
|
|
28
28
|
var _services = require("../services");
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
var _MutationEvent = require("../dom/MutationEvent");
|
|
31
|
+
|
|
32
|
+
var _shapes = require("../shapes");
|
|
33
|
+
|
|
32
34
|
var DEFAULT_STYLE_PROPS = {
|
|
33
35
|
anchor: [0, 0, 0],
|
|
34
36
|
origin: [0, 0, 0],
|
|
@@ -57,15 +59,8 @@ var DEFAULT_STYLE_PROPS = {
|
|
|
57
59
|
* * attributeChanged
|
|
58
60
|
*/
|
|
59
61
|
|
|
60
|
-
var DisplayObject =
|
|
61
|
-
|
|
62
|
-
function (_super) {
|
|
63
|
-
(0, _tslib.__extends)(DisplayObject, _super); // stylePropertyUpdaterFactory = globalContainer.get<
|
|
64
|
-
// <Key extends keyof StyleProps>(stylePropertyName: Key) => StylePropertyUpdater<any>[]
|
|
65
|
-
// >(StylePropertyUpdaterFactory);
|
|
66
|
-
// stylePropertyParserFactory = globalContainer.get<
|
|
67
|
-
// <Key extends keyof ParsedStyleProps>(stylePropertyName: Key) => StylePropertyParser<any, any>
|
|
68
|
-
// >(StylePropertyParserFactory);
|
|
62
|
+
var DisplayObject = function (_super) {
|
|
63
|
+
(0, _tslib.__extends)(DisplayObject, _super);
|
|
69
64
|
|
|
70
65
|
function DisplayObject(config) {
|
|
71
66
|
var _a, _b, _c;
|
|
@@ -85,17 +80,38 @@ function (_super) {
|
|
|
85
80
|
|
|
86
81
|
_this.id = _this.config.id || '';
|
|
87
82
|
_this.name = _this.config.name || '';
|
|
88
|
-
|
|
83
|
+
|
|
84
|
+
if (_this.config.className || _this.config.class) {
|
|
85
|
+
_this.className = _this.config.className || _this.config.class;
|
|
86
|
+
}
|
|
87
|
+
|
|
89
88
|
_this.interactive = (_b = _this.config.interactive) !== null && _b !== void 0 ? _b : true;
|
|
90
|
-
_this.nodeName = _this.config.type || _types.
|
|
89
|
+
_this.nodeName = _this.config.type || _types.Shape.GROUP; // compatible with G 3.0
|
|
91
90
|
|
|
92
91
|
_this.config.style = (0, _tslib.__assign)((0, _tslib.__assign)((0, _tslib.__assign)((0, _tslib.__assign)({}, DEFAULT_STYLE_PROPS), {
|
|
93
92
|
zIndex: (_c = _this.config.zIndex) !== null && _c !== void 0 ? _c : 0,
|
|
94
93
|
visibility: _this.config.visible === false ? 'hidden' : 'visible'
|
|
95
94
|
}), _this.config.style), _this.config.attrs);
|
|
96
|
-
_this.style = new Proxy(_this.attributes, {
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
_this.style = new Proxy((0, _tslib.__assign)((0, _tslib.__assign)({}, _this.attributes), {
|
|
96
|
+
setProperty: function setProperty(propertyName, value) {
|
|
97
|
+
_this.setAttribute(propertyName, value);
|
|
98
|
+
},
|
|
99
|
+
getPropertyValue: function getPropertyValue(propertyName) {
|
|
100
|
+
return _this.getAttribute(propertyName);
|
|
101
|
+
},
|
|
102
|
+
removeProperty: function removeProperty(propertyName) {
|
|
103
|
+
_this.removeAttribute(propertyName);
|
|
104
|
+
},
|
|
105
|
+
item: function item() {
|
|
106
|
+
return '';
|
|
107
|
+
}
|
|
108
|
+
}), {
|
|
109
|
+
get: function get(target, name) {
|
|
110
|
+
if (name in target) {
|
|
111
|
+
return target[name];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return _this.getAttribute(name);
|
|
99
115
|
},
|
|
100
116
|
set: function set(_, prop, value) {
|
|
101
117
|
_this.setAttribute(prop, value);
|
|
@@ -132,7 +148,7 @@ function (_super) {
|
|
|
132
148
|
name: this.name,
|
|
133
149
|
className: this.name,
|
|
134
150
|
interactive: this.interactive,
|
|
135
|
-
style: (0, _tslib.__assign)({}, this.
|
|
151
|
+
style: (0, _tslib.__assign)({}, this.attributes)
|
|
136
152
|
});
|
|
137
153
|
|
|
138
154
|
if (deep) {
|
|
@@ -155,51 +171,62 @@ function (_super) {
|
|
|
155
171
|
var renderable = this.renderable; // parse attributes first
|
|
156
172
|
|
|
157
173
|
for (var attributeName in attributes) {
|
|
158
|
-
var
|
|
159
|
-
|
|
174
|
+
var _a = (0, _tslib.__read)((0, _utils.formatAttribute)(attributeName, attributes[attributeName]), 2),
|
|
175
|
+
name_1 = _a[0],
|
|
176
|
+
value = _a[1];
|
|
177
|
+
|
|
178
|
+
this.attributes[name_1] = value; // @ts-ignore
|
|
160
179
|
|
|
161
|
-
this.parseStyleProperty(
|
|
180
|
+
this.parseStyleProperty(name_1, value);
|
|
162
181
|
}
|
|
163
182
|
|
|
164
183
|
var priorities = {
|
|
165
|
-
x:
|
|
166
|
-
y:
|
|
184
|
+
x: Infinity,
|
|
185
|
+
y: Infinity
|
|
167
186
|
}; // update x, y at last
|
|
168
187
|
|
|
169
188
|
var sortedNames = Object.keys(attributes).sort(function (a, b) {
|
|
170
189
|
return (priorities[a] || 0) - (priorities[b] || 0);
|
|
171
190
|
});
|
|
172
191
|
sortedNames.forEach(function (attributeName) {
|
|
173
|
-
|
|
174
|
-
|
|
192
|
+
var _a = (0, _tslib.__read)((0, _utils.formatAttribute)(attributeName, ''), 1),
|
|
193
|
+
name = _a[0]; // @ts-ignore
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
_this.updateStyleProperty(name, undefined, _this.parsedStyle[name]);
|
|
175
197
|
}); // redraw at next frame
|
|
176
198
|
|
|
177
199
|
renderable.dirty = true;
|
|
178
200
|
};
|
|
179
201
|
|
|
180
|
-
DisplayObject.prototype.setAttribute = function (
|
|
202
|
+
DisplayObject.prototype.setAttribute = function (name, value, force) {
|
|
181
203
|
if (force === void 0) {
|
|
182
204
|
force = false;
|
|
183
205
|
}
|
|
184
206
|
|
|
185
|
-
|
|
207
|
+
var _a = (0, _tslib.__read)((0, _utils.formatAttribute)(name, value), 2),
|
|
208
|
+
attributeName = _a[0],
|
|
209
|
+
attributeValue = _a[1];
|
|
210
|
+
|
|
211
|
+
if (force || !(0, _util.isEqual)(attributeValue, this.attributes[attributeName]) || attributeName === 'transformOrigin' || attributeName === 'visibility' // will affect children
|
|
186
212
|
) {
|
|
187
213
|
if (attributeName === 'visibility') {
|
|
188
214
|
// set value cascade
|
|
189
215
|
this.forEach(function (object) {
|
|
190
|
-
object.changeAttribute(attributeName,
|
|
216
|
+
object.changeAttribute(attributeName, attributeValue);
|
|
191
217
|
});
|
|
192
218
|
} else {
|
|
193
|
-
this.changeAttribute(attributeName,
|
|
219
|
+
this.changeAttribute(attributeName, attributeValue);
|
|
194
220
|
}
|
|
195
221
|
|
|
196
|
-
_super.prototype.setAttribute.call(this, attributeName,
|
|
222
|
+
_super.prototype.setAttribute.call(this, attributeName, attributeValue);
|
|
197
223
|
}
|
|
198
224
|
};
|
|
199
225
|
/**
|
|
200
226
|
* parse property, eg.
|
|
201
227
|
* * fill: 'red' => [1, 0, 0, 1]
|
|
202
228
|
* * translateX: '10px' => { unit: 'px', value: 10 }
|
|
229
|
+
* * fontSize: '2em' => { unit: 'px', value: 32 }
|
|
203
230
|
*/
|
|
204
231
|
|
|
205
232
|
|
|
@@ -209,16 +236,14 @@ function (_super) {
|
|
|
209
236
|
|
|
210
237
|
if (stylePropertyParser) {
|
|
211
238
|
// @ts-ignore
|
|
212
|
-
this.parsedStyle[name] = stylePropertyParser(value, this);
|
|
239
|
+
this.parsedStyle[name] = stylePropertyParser(value, this, name);
|
|
213
240
|
} else {
|
|
214
241
|
this.parsedStyle[name] = value;
|
|
215
242
|
}
|
|
216
243
|
};
|
|
217
244
|
|
|
218
245
|
DisplayObject.prototype.updateStyleProperty = function (name, oldParsedValue, newParsedValue) {
|
|
219
|
-
var _this = this; //
|
|
220
|
-
// @ts-ignore
|
|
221
|
-
// const stylePropertyUpdaters = this.stylePropertyUpdaterFactory(name);
|
|
246
|
+
var _this = this; // @ts-ignore
|
|
222
247
|
|
|
223
248
|
|
|
224
249
|
var stylePropertyUpdaters = _globalModule.stylePropertyUpdaterFactory[name];
|
|
@@ -226,7 +251,7 @@ function (_super) {
|
|
|
226
251
|
if (stylePropertyUpdaters) {
|
|
227
252
|
stylePropertyUpdaters.forEach(function (updater) {
|
|
228
253
|
// @ts-ignore
|
|
229
|
-
updater(oldParsedValue, newParsedValue, _this, _this.sceneGraphService);
|
|
254
|
+
updater(oldParsedValue, newParsedValue, _this, _this.sceneGraphService, name);
|
|
230
255
|
});
|
|
231
256
|
}
|
|
232
257
|
};
|
|
@@ -247,28 +272,54 @@ function (_super) {
|
|
|
247
272
|
|
|
248
273
|
this.parseStyleProperty(name, value); // @ts-ignore
|
|
249
274
|
|
|
250
|
-
|
|
275
|
+
var newParsedValue = this.parsedStyle[name]; // @ts-ignore
|
|
276
|
+
|
|
277
|
+
this.updateStyleProperty(name, oldParsedValue, newParsedValue); // inform clip path targets
|
|
251
278
|
|
|
252
279
|
if (this.attributes.clipPathTargets && this.attributes.clipPathTargets.length) {
|
|
253
280
|
this.attributes.clipPathTargets.forEach(function (target) {
|
|
254
|
-
(0, _services.dirtifyToRoot)(target);
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
281
|
+
(0, _services.dirtifyToRoot)(target); // target.emit(ElementEvent.ATTR_MODIFIED, {
|
|
282
|
+
// attributeName: 'clipPath',
|
|
283
|
+
// oldValue: this,
|
|
284
|
+
// newValue: this,
|
|
285
|
+
// });
|
|
286
|
+
|
|
287
|
+
target.dispatchEvent(new _MutationEvent.MutationEvent(_interfaces.ElementEvent.ATTR_MODIFIED, target, _this, _this, 'clipPath', _MutationEvent.MutationEvent.MODIFICATION, _this, _this));
|
|
260
288
|
});
|
|
261
289
|
} // redraw at next frame
|
|
262
290
|
|
|
263
291
|
|
|
264
292
|
renderable.dirty = true;
|
|
265
|
-
this.
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
293
|
+
this.dispatchEvent(new _MutationEvent.MutationEvent(_interfaces.ElementEvent.ATTR_MODIFIED, this, oldValue, value, name, _MutationEvent.MutationEvent.MODIFICATION, oldParsedValue, newParsedValue)); // this.emit(ElementEvent.ATTR_MODIFIED, {
|
|
294
|
+
// attrName: name,
|
|
295
|
+
// attributeName: name,
|
|
296
|
+
// prevValue: oldValue,
|
|
297
|
+
// oldValue,
|
|
298
|
+
// newValue: value,
|
|
299
|
+
// oldParsedValue,
|
|
300
|
+
// newParsedValue,
|
|
301
|
+
// });
|
|
270
302
|
}; // #region transformable
|
|
271
303
|
|
|
304
|
+
/**
|
|
305
|
+
* returns different values than getBoundingClientRect(), as the latter returns value relative to the viewport
|
|
306
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/SVGGraphicsElement/getBBox
|
|
307
|
+
*/
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
DisplayObject.prototype.getBBox = function () {
|
|
311
|
+
var aabb = this.getBounds();
|
|
312
|
+
|
|
313
|
+
var _a = (0, _tslib.__read)(aabb.getMin(), 2),
|
|
314
|
+
left = _a[0],
|
|
315
|
+
top = _a[1];
|
|
316
|
+
|
|
317
|
+
var _b = (0, _tslib.__read)(aabb.getMax(), 2),
|
|
318
|
+
right = _b[0],
|
|
319
|
+
bottom = _b[1];
|
|
320
|
+
|
|
321
|
+
return new _shapes.Rectangle(left, top, right - left, bottom - top);
|
|
322
|
+
};
|
|
272
323
|
|
|
273
324
|
DisplayObject.prototype.setOrigin = function (position, y, z) {
|
|
274
325
|
if (y === void 0) {
|
|
@@ -590,7 +641,7 @@ function (_super) {
|
|
|
590
641
|
|
|
591
642
|
DisplayObject.prototype.isVisible = function () {
|
|
592
643
|
var cullable = this.cullable;
|
|
593
|
-
return this.
|
|
644
|
+
return this.getAttribute('visibility') === 'visible' && (!cullable || cullable && !cullable.isCulled());
|
|
594
645
|
};
|
|
595
646
|
/**
|
|
596
647
|
* bring to front in current group
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import type { DisplayObjectConfig } from '../dom/interfaces';
|
|
2
2
|
import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
3
3
|
import { DisplayObject } from './DisplayObject';
|
|
4
|
+
import type { ParsedElement } from '../property-handlers';
|
|
4
5
|
export interface EllipseStyleProps extends BaseStyleProps {
|
|
5
6
|
rx: number;
|
|
6
7
|
ry: number;
|
|
7
8
|
}
|
|
8
9
|
export interface ParsedEllipseStyleProps extends ParsedBaseStyleProps {
|
|
9
|
-
rx:
|
|
10
|
-
ry:
|
|
10
|
+
rx: ParsedElement;
|
|
11
|
+
ry: ParsedElement;
|
|
12
|
+
rxInPixels: number;
|
|
13
|
+
ryInPixels: number;
|
|
11
14
|
}
|
|
12
15
|
export declare class Ellipse extends DisplayObject<EllipseStyleProps, ParsedEllipseStyleProps> {
|
|
13
|
-
constructor({ style, ...rest }
|
|
16
|
+
constructor({ style, ...rest }?: DisplayObjectConfig<EllipseStyleProps>);
|
|
14
17
|
}
|
|
@@ -11,20 +11,23 @@ var _types = require("../types");
|
|
|
11
11
|
|
|
12
12
|
var _DisplayObject = require("./DisplayObject");
|
|
13
13
|
|
|
14
|
-
var Ellipse =
|
|
15
|
-
/** @class */
|
|
16
|
-
function (_super) {
|
|
14
|
+
var Ellipse = function (_super) {
|
|
17
15
|
(0, _tslib.__extends)(Ellipse, _super);
|
|
18
16
|
|
|
19
17
|
function Ellipse(_a) {
|
|
18
|
+
if (_a === void 0) {
|
|
19
|
+
_a = {};
|
|
20
|
+
}
|
|
21
|
+
|
|
20
22
|
var style = _a.style,
|
|
21
23
|
rest = (0, _tslib.__rest)(_a, ["style"]);
|
|
22
24
|
return _super.call(this, (0, _tslib.__assign)({
|
|
23
|
-
type: _types.
|
|
25
|
+
type: _types.Shape.ELLIPSE,
|
|
24
26
|
style: (0, _tslib.__assign)({
|
|
25
27
|
rx: 0,
|
|
26
28
|
ry: 0,
|
|
27
|
-
anchor: [0.5, 0.5]
|
|
29
|
+
anchor: [0.5, 0.5],
|
|
30
|
+
lineWidth: 0
|
|
28
31
|
}, style)
|
|
29
32
|
}, rest)) || this;
|
|
30
33
|
}
|
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
import type { BaseStyleProps } from '../types';
|
|
1
|
+
import type { BaseStyleProps, ParsedBaseStyleProps, TextAlign } from '../types';
|
|
2
2
|
import { DisplayObject } from './DisplayObject';
|
|
3
3
|
import type { DisplayObjectConfig } from '../dom';
|
|
4
|
+
import type { ParsedElement } from '../property-handlers';
|
|
5
|
+
export interface GroupStyleProps extends BaseStyleProps {
|
|
6
|
+
width?: number | string;
|
|
7
|
+
height?: number | string;
|
|
8
|
+
textAlign?: TextAlign | 'inherit';
|
|
9
|
+
fontSize?: number | string | 'inherit';
|
|
10
|
+
fontFamily?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ParsedGroupStyleProps extends ParsedBaseStyleProps {
|
|
13
|
+
width?: ParsedElement;
|
|
14
|
+
height?: ParsedElement;
|
|
15
|
+
widthInPixels?: number;
|
|
16
|
+
heightInPixels?: number;
|
|
17
|
+
textAlign?: TextAlign;
|
|
18
|
+
fontSize?: ParsedElement;
|
|
19
|
+
}
|
|
4
20
|
export declare class Group extends DisplayObject {
|
|
5
|
-
constructor(
|
|
21
|
+
constructor({ style, ...rest }?: DisplayObjectConfig<GroupStyleProps>);
|
|
6
22
|
}
|
|
@@ -11,23 +11,25 @@ var _types = require("../types");
|
|
|
11
11
|
|
|
12
12
|
var _DisplayObject = require("./DisplayObject");
|
|
13
13
|
|
|
14
|
-
var Group =
|
|
15
|
-
/** @class */
|
|
16
|
-
function (_super) {
|
|
14
|
+
var Group = function (_super) {
|
|
17
15
|
(0, _tslib.__extends)(Group, _super);
|
|
18
16
|
|
|
19
|
-
function Group(
|
|
20
|
-
|
|
17
|
+
function Group(_a) {
|
|
18
|
+
if (_a === void 0) {
|
|
19
|
+
_a = {};
|
|
20
|
+
}
|
|
21
21
|
|
|
22
|
-
var
|
|
23
|
-
style = _a.style,
|
|
22
|
+
var style = _a.style,
|
|
24
23
|
rest = (0, _tslib.__rest)(_a, ["style"]);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
return _super.call(this, (0, _tslib.__assign)({
|
|
25
|
+
type: _types.Shape.GROUP,
|
|
26
|
+
style: (0, _tslib.__assign)({
|
|
27
|
+
width: 'auto',
|
|
28
|
+
height: 'auto',
|
|
29
|
+
textAlign: 'inherit',
|
|
30
|
+
fontSize: 'inherit'
|
|
31
|
+
}, style)
|
|
29
32
|
}, rest)) || this;
|
|
30
|
-
return _this;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
return Group;
|
|
@@ -2,14 +2,19 @@ import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
|
2
2
|
import { DisplayObject } from './DisplayObject';
|
|
3
3
|
import type { DisplayObjectConfig } from '../dom';
|
|
4
4
|
import { AABB } from '../shapes';
|
|
5
|
+
import type { ParsedElement } from '../property-handlers';
|
|
5
6
|
export interface HTMLStyleProps extends BaseStyleProps {
|
|
6
7
|
innerHTML: string | HTMLElement;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
7
10
|
className?: string | string[];
|
|
8
11
|
style?: string;
|
|
9
12
|
}
|
|
10
13
|
export interface ParsedHTMLStyleProps extends ParsedBaseStyleProps {
|
|
11
14
|
$el: HTMLElement;
|
|
12
15
|
innerHTML: string | HTMLElement;
|
|
16
|
+
width: ParsedElement;
|
|
17
|
+
height: ParsedElement;
|
|
13
18
|
className?: string | string[];
|
|
14
19
|
style?: string;
|
|
15
20
|
}
|
|
@@ -18,7 +23,7 @@ export interface ParsedHTMLStyleProps extends ParsedBaseStyleProps {
|
|
|
18
23
|
* @see https://github.com/pmndrs/drei#html
|
|
19
24
|
*/
|
|
20
25
|
export declare class HTML extends DisplayObject<HTMLStyleProps, ParsedHTMLStyleProps> {
|
|
21
|
-
constructor({ style, ...rest }
|
|
26
|
+
constructor({ style, ...rest }?: DisplayObjectConfig<HTMLStyleProps>);
|
|
22
27
|
/**
|
|
23
28
|
* return wrapper HTMLElement
|
|
24
29
|
* * <div> in g-webgl/canvas
|
|
@@ -19,17 +19,19 @@ var _glMatrix = require("gl-matrix");
|
|
|
19
19
|
* HTML container
|
|
20
20
|
* @see https://github.com/pmndrs/drei#html
|
|
21
21
|
*/
|
|
22
|
-
var HTML =
|
|
23
|
-
/** @class */
|
|
24
|
-
function (_super) {
|
|
22
|
+
var HTML = function (_super) {
|
|
25
23
|
(0, _tslib.__extends)(HTML, _super);
|
|
26
24
|
|
|
27
25
|
function HTML(_a) {
|
|
26
|
+
if (_a === void 0) {
|
|
27
|
+
_a = {};
|
|
28
|
+
}
|
|
29
|
+
|
|
28
30
|
var style = _a.style,
|
|
29
31
|
rest = (0, _tslib.__rest)(_a, ["style"]);
|
|
30
32
|
|
|
31
33
|
var _this = _super.call(this, (0, _tslib.__assign)({
|
|
32
|
-
type: _types.
|
|
34
|
+
type: _types.Shape.HTML,
|
|
33
35
|
style: (0, _tslib.__assign)({
|
|
34
36
|
innerHTML: '',
|
|
35
37
|
className: '',
|
|
@@ -89,7 +91,7 @@ function (_super) {
|
|
|
89
91
|
|
|
90
92
|
var bounds = this.getBounds();
|
|
91
93
|
|
|
92
|
-
if (bounds) {
|
|
94
|
+
if (!_shapes.AABB.isEmpty(bounds)) {
|
|
93
95
|
var localBounds = new _shapes.AABB();
|
|
94
96
|
localBounds.setFromTransformedAABB(bounds, parentInvert);
|
|
95
97
|
return localBounds;
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
2
2
|
import { DisplayObject } from './DisplayObject';
|
|
3
3
|
import type { DisplayObjectConfig } from '../dom';
|
|
4
|
+
import type { ParsedElement } from '../property-handlers';
|
|
4
5
|
export interface ImageStyleProps extends BaseStyleProps {
|
|
5
|
-
img
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
img?: string | HTMLImageElement;
|
|
7
|
+
src?: string | HTMLImageElement;
|
|
8
|
+
width?: number | string;
|
|
9
|
+
height?: number | string;
|
|
8
10
|
}
|
|
9
11
|
export interface ParsedImageStyleProps extends ParsedBaseStyleProps {
|
|
10
|
-
img
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
img?: string | HTMLImageElement;
|
|
13
|
+
src?: string | HTMLImageElement;
|
|
14
|
+
width?: ParsedElement;
|
|
15
|
+
height?: ParsedElement;
|
|
16
|
+
widthInPixels?: number;
|
|
17
|
+
heightInPixels?: number;
|
|
13
18
|
}
|
|
14
19
|
export declare class Image extends DisplayObject<ImageStyleProps, ParsedImageStyleProps> {
|
|
15
|
-
constructor({ style, ...rest }
|
|
20
|
+
constructor({ style, ...rest }?: DisplayObjectConfig<ImageStyleProps>);
|
|
16
21
|
}
|
|
@@ -11,18 +11,23 @@ var _types = require("../types");
|
|
|
11
11
|
|
|
12
12
|
var _DisplayObject = require("./DisplayObject");
|
|
13
13
|
|
|
14
|
-
var Image =
|
|
15
|
-
/** @class */
|
|
16
|
-
function (_super) {
|
|
14
|
+
var Image = function (_super) {
|
|
17
15
|
(0, _tslib.__extends)(Image, _super);
|
|
18
16
|
|
|
19
17
|
function Image(_a) {
|
|
18
|
+
if (_a === void 0) {
|
|
19
|
+
_a = {};
|
|
20
|
+
}
|
|
21
|
+
|
|
20
22
|
var style = _a.style,
|
|
21
23
|
rest = (0, _tslib.__rest)(_a, ["style"]);
|
|
22
24
|
return _super.call(this, (0, _tslib.__assign)({
|
|
23
|
-
type: _types.
|
|
25
|
+
type: _types.Shape.IMAGE,
|
|
24
26
|
style: (0, _tslib.__assign)({
|
|
25
|
-
img: ''
|
|
27
|
+
img: '',
|
|
28
|
+
width: 'auto',
|
|
29
|
+
height: 'auto',
|
|
30
|
+
lineWidth: 0
|
|
26
31
|
}, style)
|
|
27
32
|
}, rest)) || this;
|
|
28
33
|
}
|
|
@@ -23,7 +23,7 @@ export interface ParsedLineStyleProps extends ParsedBaseStyleProps {
|
|
|
23
23
|
isBillboard?: boolean;
|
|
24
24
|
}
|
|
25
25
|
export declare class Line extends DisplayObject<LineStyleProps, ParsedLineStyleProps> {
|
|
26
|
-
constructor({ style, ...rest }
|
|
26
|
+
constructor({ style, ...rest }?: DisplayObjectConfig<LineStyleProps>);
|
|
27
27
|
getPoint(ratio: number): Point;
|
|
28
28
|
getTotalLength(): number;
|
|
29
29
|
}
|