@antv/g 5.0.12 → 5.0.15
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/dist/index.umd.min.js +2 -2
- package/es/Canvas.js +1 -0
- package/es/canvas-module.js +7 -15
- package/es/display-objects/Circle.d.ts +3 -1
- package/es/display-objects/DisplayObject.js +6 -2
- package/es/display-objects/Ellipse.d.ts +5 -2
- package/es/display-objects/Group.js +4 -1
- package/es/display-objects/HTML.d.ts +5 -0
- package/es/display-objects/HTML.js +1 -1
- package/es/display-objects/Image.d.ts +7 -4
- package/es/display-objects/Image.js +3 -1
- package/es/display-objects/Rect.d.ts +7 -4
- package/es/display-objects/Rect.js +2 -2
- package/es/display-objects/Text.d.ts +0 -2
- package/es/display-objects/Text.js +2 -2
- package/es/dom/Element.d.ts +4 -4
- package/es/dom/Element.js +2 -1
- package/es/dom/FederatedPointerEvent.d.ts +6 -0
- package/es/dom/FederatedPointerEvent.js +8 -0
- package/es/global-module.d.ts +3 -1
- package/es/global-module.js +30 -70
- package/es/property-handlers/aabb.js +3 -4
- package/es/property-handlers/anchor.js +2 -1
- package/es/property-handlers/dimension.d.ts +2 -1
- package/es/property-handlers/dimension.js +30 -2
- package/es/property-handlers/path.d.ts +1 -1
- package/es/services/SceneGraphService.d.ts +7 -9
- package/es/services/SceneGraphService.js +59 -71
- package/es/services/aabb/CircleUpdater.d.ts +2 -2
- package/es/services/aabb/CircleUpdater.js +19 -9
- package/es/services/aabb/EllipseUpdater.d.ts +2 -2
- package/es/services/aabb/EllipseUpdater.js +26 -11
- package/es/services/aabb/RectUpdater.d.ts +2 -2
- package/es/services/aabb/RectUpdater.js +30 -14
- package/es/services/aabb/interfaces.d.ts +1 -1
- package/es/services/aabb/interfaces.js +1 -1
- package/es/shapes/AABB.d.ts +1 -0
- package/es/shapes/AABB.js +8 -0
- package/es/types.d.ts +0 -3
- package/es/utils/path.d.ts +1 -1
- package/es/utils/path.js +5 -5
- package/lib/Canvas.js +1 -0
- package/lib/canvas-module.js +9 -16
- package/lib/display-objects/Circle.d.ts +3 -1
- package/lib/display-objects/DisplayObject.js +6 -2
- package/lib/display-objects/Ellipse.d.ts +5 -2
- package/lib/display-objects/Group.js +4 -1
- package/lib/display-objects/HTML.d.ts +5 -0
- package/lib/display-objects/HTML.js +1 -1
- package/lib/display-objects/Image.d.ts +7 -4
- package/lib/display-objects/Image.js +3 -1
- package/lib/display-objects/Rect.d.ts +7 -4
- package/lib/display-objects/Rect.js +2 -2
- package/lib/display-objects/Text.d.ts +0 -2
- package/lib/display-objects/Text.js +2 -2
- package/lib/dom/Element.d.ts +4 -4
- package/lib/dom/Element.js +2 -1
- package/lib/dom/FederatedPointerEvent.d.ts +6 -0
- package/lib/dom/FederatedPointerEvent.js +8 -0
- package/lib/global-module.d.ts +3 -1
- package/lib/global-module.js +34 -70
- package/lib/property-handlers/aabb.js +3 -4
- package/lib/property-handlers/anchor.js +3 -1
- package/lib/property-handlers/dimension.d.ts +2 -1
- package/lib/property-handlers/dimension.js +33 -2
- package/lib/property-handlers/path.d.ts +1 -1
- package/lib/services/SceneGraphService.d.ts +7 -9
- package/lib/services/SceneGraphService.js +59 -71
- package/lib/services/aabb/CircleUpdater.d.ts +2 -2
- package/lib/services/aabb/CircleUpdater.js +19 -9
- package/lib/services/aabb/EllipseUpdater.d.ts +2 -2
- package/lib/services/aabb/EllipseUpdater.js +26 -11
- package/lib/services/aabb/RectUpdater.d.ts +2 -2
- package/lib/services/aabb/RectUpdater.js +30 -14
- package/lib/services/aabb/interfaces.d.ts +1 -1
- package/lib/services/aabb/interfaces.js +1 -1
- package/lib/shapes/AABB.d.ts +1 -0
- package/lib/shapes/AABB.js +8 -0
- package/lib/types.d.ts +0 -3
- package/lib/utils/path.d.ts +1 -1
- package/lib/utils/path.js +5 -5
- package/package.json +4 -4
|
@@ -1,14 +1,17 @@
|
|
|
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 RectStyleProps extends BaseStyleProps {
|
|
5
|
-
width: number;
|
|
6
|
-
height: number;
|
|
6
|
+
width: number | string;
|
|
7
|
+
height: number | string;
|
|
7
8
|
radius?: number;
|
|
8
9
|
}
|
|
9
10
|
export interface ParsedRectStyleProps extends ParsedBaseStyleProps {
|
|
10
|
-
width:
|
|
11
|
-
height:
|
|
11
|
+
width: ParsedElement;
|
|
12
|
+
height: ParsedElement;
|
|
13
|
+
widthInPixels: number;
|
|
14
|
+
heightInPixels: number;
|
|
12
15
|
radius?: number;
|
|
13
16
|
}
|
|
14
17
|
export declare class Rect extends DisplayObject<RectStyleProps, ParsedRectStyleProps> {
|
|
@@ -22,7 +22,6 @@ export interface TextStyleProps extends BaseStyleProps {
|
|
|
22
22
|
lineHeight?: number;
|
|
23
23
|
letterSpacing?: number;
|
|
24
24
|
miterLimit?: number;
|
|
25
|
-
padding?: number;
|
|
26
25
|
whiteSpace?: 'pre';
|
|
27
26
|
leading?: number;
|
|
28
27
|
wordWrap?: boolean;
|
|
@@ -50,7 +49,6 @@ export interface ParsedTextStyleProps extends ParsedBaseStyleProps {
|
|
|
50
49
|
lineHeight?: number;
|
|
51
50
|
letterSpacing?: number;
|
|
52
51
|
miterLimit?: number;
|
|
53
|
-
padding?: number;
|
|
54
52
|
whiteSpace?: 'pre';
|
|
55
53
|
leading?: number;
|
|
56
54
|
wordWrap?: boolean;
|
|
@@ -43,11 +43,11 @@ function (_super) {
|
|
|
43
43
|
lineCap: _types.LINE_CAP.Butt,
|
|
44
44
|
lineWidth: 0,
|
|
45
45
|
miterLimit: 10,
|
|
46
|
-
padding: 0,
|
|
46
|
+
// padding: 0,
|
|
47
47
|
stroke: '#000',
|
|
48
48
|
whiteSpace: 'pre',
|
|
49
49
|
wordWrap: false,
|
|
50
|
-
wordWrapWidth:
|
|
50
|
+
wordWrapWidth: 0,
|
|
51
51
|
leading: 0
|
|
52
52
|
}, style)
|
|
53
53
|
}, rest)) || this;
|
package/lib/dom/Element.d.ts
CHANGED
|
@@ -103,16 +103,16 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
|
|
|
103
103
|
*/
|
|
104
104
|
destroyed: boolean;
|
|
105
105
|
destroy(): void;
|
|
106
|
-
getGeometryBounds(): AABB
|
|
107
|
-
getRenderBounds(): AABB
|
|
106
|
+
getGeometryBounds(): AABB;
|
|
107
|
+
getRenderBounds(): AABB;
|
|
108
108
|
/**
|
|
109
109
|
* get bounds in world space, account for children
|
|
110
110
|
*/
|
|
111
|
-
getBounds(): AABB
|
|
111
|
+
getBounds(): AABB;
|
|
112
112
|
/**
|
|
113
113
|
* get bounds in local space, account for children
|
|
114
114
|
*/
|
|
115
|
-
getLocalBounds(): AABB
|
|
115
|
+
getLocalBounds(): AABB;
|
|
116
116
|
/**
|
|
117
117
|
* account for context's bounds in client space,
|
|
118
118
|
* but not accounting for children
|
package/lib/dom/Element.js
CHANGED
|
@@ -64,6 +64,12 @@ export declare class FederatedPointerEvent extends FederatedMouseEvent implement
|
|
|
64
64
|
* @see https://w3c.github.io/pointerevents/#pointerevent-interface
|
|
65
65
|
*/
|
|
66
66
|
twist: number;
|
|
67
|
+
/**
|
|
68
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/getCoalescedEvents
|
|
69
|
+
*/
|
|
67
70
|
getCoalescedEvents(): PointerEvent[];
|
|
71
|
+
/**
|
|
72
|
+
* @see https://chromestatus.com/feature/5765569655603200
|
|
73
|
+
*/
|
|
68
74
|
getPredictedEvents(): PointerEvent[];
|
|
69
75
|
}
|
|
@@ -42,6 +42,10 @@ function (_super) {
|
|
|
42
42
|
_this.isPrimary = false;
|
|
43
43
|
return _this;
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/getCoalescedEvents
|
|
47
|
+
*/
|
|
48
|
+
|
|
45
49
|
|
|
46
50
|
FederatedPointerEvent.prototype.getCoalescedEvents = function () {
|
|
47
51
|
if (this.type === 'pointermove' || this.type === 'mousemove' || this.type === 'touchmove') {
|
|
@@ -50,6 +54,10 @@ function (_super) {
|
|
|
50
54
|
|
|
51
55
|
return [];
|
|
52
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* @see https://chromestatus.com/feature/5765569655603200
|
|
59
|
+
*/
|
|
60
|
+
|
|
53
61
|
|
|
54
62
|
FederatedPointerEvent.prototype.getPredictedEvents = function () {
|
|
55
63
|
throw new Error('getPredictedEvents is not supported!');
|
package/lib/global-module.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type { StylePropertyParser, StylePropertyMerger, StylePropertyUpdater } from './property-handlers';
|
|
1
|
+
import type { Interpolatable, StylePropertyParser, StylePropertyMerger, StylePropertyUpdater } from './property-handlers';
|
|
2
2
|
export declare const globalContainer: import("mana-syringe").Container;
|
|
3
3
|
export declare const stylePropertyParserFactory: Record<string, StylePropertyParser<any, any>>;
|
|
4
4
|
export declare const stylePropertyUpdaterFactory: Record<string, StylePropertyUpdater<any>[]>;
|
|
5
5
|
export declare const stylePropertyMergerFactory: Record<string, StylePropertyMerger<any, any>>;
|
|
6
|
+
export declare function addPropertyHandler<O, P, I extends Interpolatable = number>(property: string, parser: StylePropertyParser<O, P> | undefined, merger: StylePropertyMerger<P, I> | undefined, updater: StylePropertyUpdater<O> | undefined): void;
|
|
7
|
+
export declare function addPropertiesHandler<O, P, I extends Interpolatable = number>(properties: string[], parser: StylePropertyParser<O, P> | undefined, merger: StylePropertyMerger<P, I> | undefined, updater: StylePropertyUpdater<O> | undefined): void;
|
|
6
8
|
export declare const containerModule: import("mana-syringe").SyringeModule;
|
package/lib/global-module.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.addPropertiesHandler = addPropertiesHandler;
|
|
7
|
+
exports.addPropertyHandler = addPropertyHandler;
|
|
6
8
|
exports.stylePropertyUpdaterFactory = exports.stylePropertyParserFactory = exports.stylePropertyMergerFactory = exports.globalContainer = exports.containerModule = void 0;
|
|
7
9
|
|
|
8
10
|
var _manaSyringe = require("mana-syringe");
|
|
@@ -33,6 +35,31 @@ var stylePropertyUpdaterFactory = {};
|
|
|
33
35
|
exports.stylePropertyUpdaterFactory = stylePropertyUpdaterFactory;
|
|
34
36
|
var stylePropertyMergerFactory = {};
|
|
35
37
|
exports.stylePropertyMergerFactory = stylePropertyMergerFactory;
|
|
38
|
+
|
|
39
|
+
function addPropertyHandler(property, parser, merger, updater) {
|
|
40
|
+
if (parser) {
|
|
41
|
+
stylePropertyParserFactory[property] = parser; // register({ token: { token: StylePropertyParser, named: property }, useValue: parser });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (merger) {
|
|
45
|
+
stylePropertyMergerFactory[property] = merger; // register({ token: { token: StylePropertyMerger, named: property }, useValue: merger });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (updater) {
|
|
49
|
+
if (!stylePropertyUpdaterFactory[property]) {
|
|
50
|
+
stylePropertyUpdaterFactory[property] = [];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
stylePropertyUpdaterFactory[property].push(updater); // register({ token: { token: StylePropertyUpdater, named: property }, useValue: updater });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function addPropertiesHandler(properties, parser, merger, updater) {
|
|
58
|
+
for (var i = 0; i < properties.length; i++) {
|
|
59
|
+
addPropertyHandler(properties[i], parser, merger, updater);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
36
63
|
var containerModule = (0, _manaSyringe.Module)(function (register) {
|
|
37
64
|
(0, _manaSyringe.decorate)((0, _manaSyringe.injectable)(), _eventemitter.EventEmitter); // bind DisplayObject pool
|
|
38
65
|
|
|
@@ -80,81 +107,18 @@ var containerModule = (0, _manaSyringe.Module)(function (register) {
|
|
|
80
107
|
return cache[tagName];
|
|
81
108
|
};
|
|
82
109
|
}
|
|
83
|
-
}); //
|
|
84
|
-
// register({
|
|
85
|
-
// token: StylePropertyParserFactory,
|
|
86
|
-
// useFactory: (context) => {
|
|
87
|
-
// const cache = {};
|
|
88
|
-
// return (propertyName: string) => {
|
|
89
|
-
// if (!cache[propertyName]) {
|
|
90
|
-
// if (context.container.isBoundNamed(StylePropertyParser, propertyName)) {
|
|
91
|
-
// cache[propertyName] = context.container.getNamed(StylePropertyParser, propertyName);
|
|
92
|
-
// }
|
|
93
|
-
// }
|
|
94
|
-
// return cache[propertyName];
|
|
95
|
-
// };
|
|
96
|
-
// },
|
|
97
|
-
// });
|
|
98
|
-
// register({
|
|
99
|
-
// token: StylePropertyUpdaterFactory,
|
|
100
|
-
// useFactory: (context) => {
|
|
101
|
-
// const cache = {};
|
|
102
|
-
// return (propertyName: string) => {
|
|
103
|
-
// if (!cache[propertyName]) {
|
|
104
|
-
// if (context.container.isBoundNamed(StylePropertyUpdater, propertyName)) {
|
|
105
|
-
// cache[propertyName] = context.container.getAllNamed(StylePropertyUpdater, propertyName);
|
|
106
|
-
// }
|
|
107
|
-
// }
|
|
108
|
-
// return cache[propertyName];
|
|
109
|
-
// };
|
|
110
|
-
// },
|
|
111
|
-
// });
|
|
112
|
-
// register({
|
|
113
|
-
// token: StylePropertyMergerFactory,
|
|
114
|
-
// useFactory: (context) => {
|
|
115
|
-
// const cache = {};
|
|
116
|
-
// return (propertyName: string) => {
|
|
117
|
-
// if (!cache[propertyName]) {
|
|
118
|
-
// if (context.container.isBoundNamed(StylePropertyMerger, propertyName)) {
|
|
119
|
-
// cache[propertyName] = context.container.getNamed(StylePropertyMerger, propertyName);
|
|
120
|
-
// }
|
|
121
|
-
// }
|
|
122
|
-
// return cache[propertyName];
|
|
123
|
-
// };
|
|
124
|
-
// },
|
|
125
|
-
// });
|
|
126
|
-
|
|
127
|
-
function addPropertyHandler(property, parser, merger, updater) {
|
|
128
|
-
if (parser) {
|
|
129
|
-
stylePropertyParserFactory[property] = parser; // register({ token: { token: StylePropertyParser, named: property }, useValue: parser });
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (merger) {
|
|
133
|
-
stylePropertyMergerFactory[property] = merger; // register({ token: { token: StylePropertyMerger, named: property }, useValue: merger });
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (updater) {
|
|
137
|
-
if (!stylePropertyUpdaterFactory[property]) {
|
|
138
|
-
stylePropertyUpdaterFactory[property] = [];
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
stylePropertyUpdaterFactory[property].push(updater); // register({ token: { token: StylePropertyUpdater, named: property }, useValue: updater });
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function addPropertiesHandler(properties, parser, merger, updater) {
|
|
146
|
-
for (var i = 0; i < properties.length; i++) {
|
|
147
|
-
addPropertyHandler(properties[i], parser, merger, updater);
|
|
148
|
-
}
|
|
149
|
-
} // bind handlers for properties
|
|
150
|
-
|
|
110
|
+
}); // bind handlers for properties
|
|
151
111
|
|
|
152
112
|
addPropertiesHandler(['opacity', 'fillOpacity', 'strokeOpacity', 'offsetDistance'], _propertyHandlers.parseNumber, (0, _propertyHandlers.clampedMergeNumbers)(0, 1), undefined);
|
|
153
|
-
addPropertiesHandler(['
|
|
113
|
+
addPropertiesHandler(['lineWidth', 'shadowBlur'], _propertyHandlers.parseNumber, (0, _propertyHandlers.clampedMergeNumbers)(0, Infinity), undefined); // support percent
|
|
114
|
+
|
|
115
|
+
addPropertiesHandler(['r', 'rx', 'ry', 'width', 'height'], _propertyHandlers.parseLengthOrPercent, // @ts-ignore
|
|
116
|
+
_propertyHandlers.mergeDimensions, undefined);
|
|
154
117
|
addPropertiesHandler(['lineDash'], _propertyHandlers.parseLineDash, // @ts-ignore
|
|
155
118
|
_propertyHandlers.mergeNumberLists, undefined);
|
|
156
119
|
addPropertiesHandler(['x1', 'x2', 'y1', 'y2', 'lineDashOffset', 'shadowOffsetX', 'shadowOffsetY'], _propertyHandlers.parseNumber, _propertyHandlers.mergeNumbers, undefined);
|
|
157
|
-
addPropertiesHandler(['x1', 'x2', 'y1', 'y2', 'r', 'rx', 'ry', 'width', 'height', 'path', 'points', 'text', 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY', 'lineWidth', 'filter', 'font', 'fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', 'padding',
|
|
120
|
+
addPropertiesHandler(['x1', 'x2', 'y1', 'y2', 'r', 'rx', 'ry', 'width', 'height', 'path', 'points', 'text', 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY', 'lineWidth', 'filter', 'font', 'fontSize', 'fontFamily', 'fontStyle', 'fontWeight', 'fontVariant', 'lineHeight', 'letterSpacing', // 'padding',
|
|
121
|
+
'wordWrap', 'wordWrapWidth', 'leading', 'textBaseline', 'textAlign', 'whiteSpace'], undefined, undefined, _propertyHandlers.updateGeometry);
|
|
158
122
|
addPropertiesHandler(['fill', 'stroke', 'shadowColor'], _propertyHandlers.parseColor, _propertyHandlers.mergeColors, undefined);
|
|
159
123
|
addPropertyHandler('clipPath', undefined, undefined, _propertyHandlers.updateClipPath);
|
|
160
124
|
addPropertyHandler('zIndex', undefined, undefined, _propertyHandlers.updateZIndex);
|
|
@@ -49,11 +49,10 @@ function updateGeometry(oldValue, newValue, object) {
|
|
|
49
49
|
_g = _a.offsetY,
|
|
50
50
|
offsetY = _g === void 0 ? 0 : _g,
|
|
51
51
|
_h = _a.offsetZ,
|
|
52
|
-
offsetZ = _h === void 0 ? 0 : _h;
|
|
52
|
+
offsetZ = _h === void 0 ? 0 : _h; // object.parsedStyle.width = width;
|
|
53
|
+
// object.parsedStyle.height = height;
|
|
54
|
+
// object.parsedStyle.depth = depth;
|
|
53
55
|
|
|
54
|
-
object.parsedStyle.width = width;
|
|
55
|
-
object.parsedStyle.height = height;
|
|
56
|
-
object.parsedStyle.depth = depth;
|
|
57
56
|
|
|
58
57
|
if (object.nodeName === _types.SHAPE.Line || object.nodeName === _types.SHAPE.Polyline || object.nodeName === _types.SHAPE.Polygon || object.nodeName === _types.SHAPE.Path) {
|
|
59
58
|
object.parsedStyle.offsetX = x - (object.parsedStyle.defX || 0);
|
|
@@ -11,12 +11,14 @@ var _glMatrix = require("gl-matrix");
|
|
|
11
11
|
|
|
12
12
|
var _services = require("../services");
|
|
13
13
|
|
|
14
|
+
var _shapes = require("../shapes");
|
|
15
|
+
|
|
14
16
|
var _utils = require("../utils");
|
|
15
17
|
|
|
16
18
|
function updateAnchor(oldValue, newValue, object) {
|
|
17
19
|
var bounds = object.getGeometryBounds();
|
|
18
20
|
|
|
19
|
-
if (bounds) {
|
|
21
|
+
if (!_shapes.AABB.isEmpty(bounds)) {
|
|
20
22
|
var geometry = object.geometry;
|
|
21
23
|
|
|
22
24
|
if (geometry && geometry.contentBounds) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DisplayObject } from '../display-objects/DisplayObject';
|
|
2
2
|
export declare type LengthUnit = 'px' | '%';
|
|
3
3
|
export declare type AngleUnit = 'deg' | 'rad' | 'turn';
|
|
4
|
-
export declare type Unit = LengthUnit | AngleUnit | '';
|
|
4
|
+
export declare type Unit = LengthUnit | AngleUnit | '' | 'auto';
|
|
5
5
|
export interface ParsedElement {
|
|
6
6
|
unit: Unit;
|
|
7
7
|
value: number;
|
|
@@ -14,5 +14,6 @@ export declare function mergeDimensions(left: ParsedElement, right: ParsedElemen
|
|
|
14
14
|
export declare const parseLength: any;
|
|
15
15
|
export declare const parseLengthOrPercent: any;
|
|
16
16
|
export declare const parseAngle: any;
|
|
17
|
+
export declare function parseLengthOrPercentList(list: (string | number)[]): ParsedElement[];
|
|
17
18
|
export declare function convertPercentUnit(valueWithUnit: ParsedElement, vec3Index: number, target: DisplayObject | null): number;
|
|
18
19
|
export declare function convertAngleUnit(valueWithUnit: ParsedElement): number;
|
|
@@ -9,6 +9,7 @@ exports.mergeDimensions = mergeDimensions;
|
|
|
9
9
|
exports.parseAngle = void 0;
|
|
10
10
|
exports.parseDimension = parseDimension;
|
|
11
11
|
exports.parseLengthOrPercent = exports.parseLength = void 0;
|
|
12
|
+
exports.parseLengthOrPercentList = parseLengthOrPercentList;
|
|
12
13
|
|
|
13
14
|
var _numeric = require("./numeric");
|
|
14
15
|
|
|
@@ -16,6 +17,8 @@ var _math = require("../utils/math");
|
|
|
16
17
|
|
|
17
18
|
var _util = require("@antv/util");
|
|
18
19
|
|
|
20
|
+
var _shapes = require("../shapes");
|
|
21
|
+
|
|
19
22
|
function isLengthUnit(unit) {
|
|
20
23
|
return unit === 'px' || unit === '%';
|
|
21
24
|
}
|
|
@@ -25,7 +28,7 @@ function isAngleUnit(unit) {
|
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
function parseDimension(unitRegExp, string) {
|
|
28
|
-
string = string.trim().toLowerCase();
|
|
31
|
+
string = ("" + string).trim().toLowerCase();
|
|
29
32
|
|
|
30
33
|
if (string === '0') {
|
|
31
34
|
if ('px'.search(unitRegExp) >= 0) {
|
|
@@ -41,6 +44,11 @@ function parseDimension(unitRegExp, string) {
|
|
|
41
44
|
value: 0
|
|
42
45
|
};
|
|
43
46
|
}
|
|
47
|
+
} else if (string === 'auto') {
|
|
48
|
+
return {
|
|
49
|
+
unit: 'auto',
|
|
50
|
+
value: 0
|
|
51
|
+
};
|
|
44
52
|
}
|
|
45
53
|
|
|
46
54
|
if ((0, _util.isFinite)(Number(string))) {
|
|
@@ -111,6 +119,29 @@ exports.parseLengthOrPercent = parseLengthOrPercent;
|
|
|
111
119
|
var parseAngle = parseDimension.bind(null, /deg|rad|grad|turn/g);
|
|
112
120
|
exports.parseAngle = parseAngle;
|
|
113
121
|
|
|
122
|
+
function parseLengthOrPercentList(list) {
|
|
123
|
+
return list.map(parseLengthOrPercent);
|
|
124
|
+
} // export function mergeDimensionsLists(
|
|
125
|
+
// left: ParsedElement[],
|
|
126
|
+
// right: ParsedElement[],
|
|
127
|
+
// target: DisplayObject | null,
|
|
128
|
+
// ): [ParsedElement[], ParsedElement[], (list: ParsedElement[]) => string] | undefined {
|
|
129
|
+
// if (left.length != right.length) {
|
|
130
|
+
// return;
|
|
131
|
+
// }
|
|
132
|
+
// return [
|
|
133
|
+
// leftValue,
|
|
134
|
+
// rightValue,
|
|
135
|
+
// (value: number) => {
|
|
136
|
+
// if (nonNegative) {
|
|
137
|
+
// value = Math.max(value, 0);
|
|
138
|
+
// }
|
|
139
|
+
// return numberToString(value) + unit;
|
|
140
|
+
// },
|
|
141
|
+
// ];
|
|
142
|
+
// }
|
|
143
|
+
|
|
144
|
+
|
|
114
145
|
function convertPercentUnit(valueWithUnit, vec3Index, target) {
|
|
115
146
|
if (valueWithUnit.unit === 'px') {
|
|
116
147
|
return Number(valueWithUnit.value);
|
|
@@ -119,7 +150,7 @@ function convertPercentUnit(valueWithUnit, vec3Index, target) {
|
|
|
119
150
|
var bounds = target.getBounds();
|
|
120
151
|
var size = 0;
|
|
121
152
|
|
|
122
|
-
if (bounds) {
|
|
153
|
+
if (!_shapes.AABB.isEmpty(bounds)) {
|
|
123
154
|
size = bounds.halfExtents[vec3Index] * 2;
|
|
124
155
|
}
|
|
125
156
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { PathCommand } from '../types';
|
|
2
2
|
import type { ParsedPathStyleProps } from '../display-objects';
|
|
3
3
|
export declare function parsePath(path: string): ParsedPathStyleProps;
|
|
4
|
-
export declare function mergePaths(left: ParsedPathStyleProps, right: ParsedPathStyleProps): ((string[] | ["a" | "A", number, number, number, number, number, number, number] | ["C" | "c", number, number, number, number, number, number] | ["o" | "O", number, number] | ["h" | "H", number] | ["l" | "L", number, number] | ["
|
|
4
|
+
export declare function mergePaths(left: ParsedPathStyleProps, right: ParsedPathStyleProps): ((string[] | ["a" | "A", number, number, number, number, number, number, number] | ["C" | "c", number, number, number, number, number, number] | ["o" | "O", number, number] | ["h" | "H", number] | ["l" | "L", number, number] | ["m" | "M", number, number] | ["r" | "R", number, number, number, number] | ["q" | "Q", number, number, number, number] | ["s" | "S", number, number, number, number, number, number, number] | ["t" | "T", number, number] | ["v" | "V", number] | ["u" | "U", number, number, number])[] | ((pathArray: PathCommand[]) => PathCommand[]))[];
|
|
@@ -12,7 +12,6 @@ export interface SceneGraphService {
|
|
|
12
12
|
querySelectorAll: <R extends IElement, T extends IElement>(query: string, root: R) => T[];
|
|
13
13
|
attach: <C extends INode, P extends INode & IParentNode>(child: C, parent: P, index?: number) => void;
|
|
14
14
|
detach: <C extends INode>(child: C) => void;
|
|
15
|
-
sort: (object1: IElement, object2: IElement) => number;
|
|
16
15
|
getOrigin: (element: INode) => vec3;
|
|
17
16
|
setOrigin: (element: INode, origin: vec3 | number, y?: number, z?: number) => void;
|
|
18
17
|
setPosition: (element: INode, position: vec3 | vec2) => void;
|
|
@@ -36,9 +35,9 @@ export interface SceneGraphService {
|
|
|
36
35
|
getWorldTransform: (element: INode, transform?: Transform) => mat4;
|
|
37
36
|
getLocalTransform: (element: INode, transform?: Transform) => mat4;
|
|
38
37
|
resetLocalTransform: (element: INode) => void;
|
|
39
|
-
getBounds: (element: INode, render?: boolean) => AABB
|
|
40
|
-
getLocalBounds: (element: INode, render?: boolean) => AABB
|
|
41
|
-
getGeometryBounds: (element: INode, render?: boolean) => AABB
|
|
38
|
+
getBounds: (element: INode, render?: boolean) => AABB;
|
|
39
|
+
getLocalBounds: (element: INode, render?: boolean) => AABB;
|
|
40
|
+
getGeometryBounds: (element: INode, render?: boolean) => AABB;
|
|
42
41
|
getBoundingClientRect: (element: INode) => Rectangle;
|
|
43
42
|
syncHierarchy: (element: INode) => void;
|
|
44
43
|
}
|
|
@@ -60,7 +59,6 @@ export declare class DefaultSceneGraphService implements SceneGraphService {
|
|
|
60
59
|
* use materialized path
|
|
61
60
|
* @see https://stackoverflow.com/questions/31470730/comparing-tree-nodes
|
|
62
61
|
*/
|
|
63
|
-
sort: (object1: INode, object2: INode) => number;
|
|
64
62
|
getOrigin(element: INode): vec3;
|
|
65
63
|
setOrigin(element: INode, origin: vec3 | number, y?: number, z?: number): void;
|
|
66
64
|
/**
|
|
@@ -132,19 +130,19 @@ export declare class DefaultSceneGraphService implements SceneGraphService {
|
|
|
132
130
|
getLocalScale(element: INode): vec3;
|
|
133
131
|
getLocalTransform(element: INode): mat4;
|
|
134
132
|
resetLocalTransform(element: INode): void;
|
|
135
|
-
getTransformedGeometryBounds
|
|
133
|
+
private getTransformedGeometryBounds;
|
|
136
134
|
/**
|
|
137
135
|
* won't account for children
|
|
138
136
|
*/
|
|
139
|
-
getGeometryBounds(element: INode, render?: boolean): AABB
|
|
137
|
+
getGeometryBounds(element: INode, render?: boolean): AABB;
|
|
140
138
|
/**
|
|
141
139
|
* account for children in world space
|
|
142
140
|
*/
|
|
143
|
-
getBounds(element: INode, render?: boolean): AABB
|
|
141
|
+
getBounds(element: INode, render?: boolean): AABB;
|
|
144
142
|
/**
|
|
145
143
|
* account for children in local space
|
|
146
144
|
*/
|
|
147
|
-
getLocalBounds(element: INode): AABB
|
|
145
|
+
getLocalBounds(element: INode): AABB;
|
|
148
146
|
getBoundingClientRect(element: INode): Rectangle;
|
|
149
147
|
private dirtifyWorldInternal;
|
|
150
148
|
syncHierarchy(element: INode): void;
|
|
@@ -76,72 +76,6 @@ var DefaultSceneGraphService =
|
|
|
76
76
|
function () {
|
|
77
77
|
function DefaultSceneGraphService() {
|
|
78
78
|
var _this = this;
|
|
79
|
-
/**
|
|
80
|
-
* compare two display objects by hierarchy-index and z-index
|
|
81
|
-
*
|
|
82
|
-
* use materialized path
|
|
83
|
-
* @see https://stackoverflow.com/questions/31470730/comparing-tree-nodes
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
this.sort = function (object1, object2) {
|
|
88
|
-
if (!object1.parentNode) {
|
|
89
|
-
return -1;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (!object2.parentNode) {
|
|
93
|
-
return 1;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
var hierarchyDiff = object1.transformable.graphDepth - object2.transformable.graphDepth;
|
|
97
|
-
var o1 = object1;
|
|
98
|
-
var o2 = object2;
|
|
99
|
-
|
|
100
|
-
if (hierarchyDiff < 0) {
|
|
101
|
-
o2 = object2.getAncestor(-hierarchyDiff);
|
|
102
|
-
|
|
103
|
-
if (o2 === o1) {
|
|
104
|
-
return -1;
|
|
105
|
-
}
|
|
106
|
-
} else if (hierarchyDiff > 0) {
|
|
107
|
-
o1 = object1.getAncestor(hierarchyDiff);
|
|
108
|
-
|
|
109
|
-
if (o2 === o1) {
|
|
110
|
-
return 1;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
while (o1 && o2 && o1.parentNode !== o2.parentNode) {
|
|
115
|
-
o1 = o1.parentNode;
|
|
116
|
-
o2 = o2.parentNode;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
var parent = o1.parentNode;
|
|
120
|
-
|
|
121
|
-
if (parent) {
|
|
122
|
-
var parentSortable = parent.sortable;
|
|
123
|
-
|
|
124
|
-
if (parentSortable) {
|
|
125
|
-
// no need to re-sort, use cached sorted children
|
|
126
|
-
if (!parentSortable.sorted) {
|
|
127
|
-
parentSortable.sorted = parent.childNodes.slice();
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (parentSortable.dirty) {
|
|
131
|
-
parentSortable.sorted = parent.childNodes.slice().sort(sortByZIndex); // parentSortable.sorted.forEach(
|
|
132
|
-
// (child, i) => ((child as Element).sortable.lastSortedIndex = i),
|
|
133
|
-
// );
|
|
134
|
-
|
|
135
|
-
parentSortable.dirty = false;
|
|
136
|
-
} // return (o1 as Element).sortable.lastSortedIndex - (o2 as Element).sortable.lastSortedIndex;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return parentSortable.sorted.indexOf(o1) - parentSortable.sorted.indexOf(o2);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return -1;
|
|
144
|
-
};
|
|
145
79
|
/**
|
|
146
80
|
* rotate in world space
|
|
147
81
|
*/
|
|
@@ -482,6 +416,60 @@ function () {
|
|
|
482
416
|
child.parentNode = null;
|
|
483
417
|
}
|
|
484
418
|
};
|
|
419
|
+
/**
|
|
420
|
+
* compare two display objects by hierarchy-index and z-index
|
|
421
|
+
*
|
|
422
|
+
* use materialized path
|
|
423
|
+
* @see https://stackoverflow.com/questions/31470730/comparing-tree-nodes
|
|
424
|
+
*/
|
|
425
|
+
// sort = (object1: INode, object2: INode): number => {
|
|
426
|
+
// if (!object1.parentNode) {
|
|
427
|
+
// return -1;
|
|
428
|
+
// }
|
|
429
|
+
// if (!object2.parentNode) {
|
|
430
|
+
// return 1;
|
|
431
|
+
// }
|
|
432
|
+
// const hierarchyDiff =
|
|
433
|
+
// (object1 as Element).transformable.graphDepth - (object2 as Element).transformable.graphDepth;
|
|
434
|
+
// let o1 = object1;
|
|
435
|
+
// let o2 = object2;
|
|
436
|
+
// if (hierarchyDiff < 0) {
|
|
437
|
+
// o2 = object2.getAncestor(-hierarchyDiff)!;
|
|
438
|
+
// if (o2 === o1) {
|
|
439
|
+
// return -1;
|
|
440
|
+
// }
|
|
441
|
+
// } else if (hierarchyDiff > 0) {
|
|
442
|
+
// o1 = object1.getAncestor(hierarchyDiff)!;
|
|
443
|
+
// if (o2 === o1) {
|
|
444
|
+
// return 1;
|
|
445
|
+
// }
|
|
446
|
+
// }
|
|
447
|
+
// while (o1 && o2 && o1.parentNode !== o2.parentNode) {
|
|
448
|
+
// o1 = o1.parentNode!;
|
|
449
|
+
// o2 = o2.parentNode!;
|
|
450
|
+
// }
|
|
451
|
+
// const parent = o1.parentNode;
|
|
452
|
+
// if (parent) {
|
|
453
|
+
// const parentSortable = (parent as Element).sortable;
|
|
454
|
+
// if (parentSortable) {
|
|
455
|
+
// // no need to re-sort, use cached sorted children
|
|
456
|
+
// if (!parentSortable.sorted) {
|
|
457
|
+
// parentSortable.sorted = (parent.childNodes as IElement[]).slice();
|
|
458
|
+
// }
|
|
459
|
+
// if (parentSortable.dirty) {
|
|
460
|
+
// parentSortable.sorted = (parent.childNodes as IElement[]).slice().sort(sortByZIndex);
|
|
461
|
+
// // parentSortable.sorted.forEach(
|
|
462
|
+
// // (child, i) => ((child as Element).sortable.lastSortedIndex = i),
|
|
463
|
+
// // );
|
|
464
|
+
// parentSortable.dirty = false;
|
|
465
|
+
// }
|
|
466
|
+
// // return (o1 as Element).sortable.lastSortedIndex - (o2 as Element).sortable.lastSortedIndex;
|
|
467
|
+
// return parentSortable.sorted.indexOf(o1) - parentSortable.sorted.indexOf(o2);
|
|
468
|
+
// }
|
|
469
|
+
// }
|
|
470
|
+
// return -1;
|
|
471
|
+
// };
|
|
472
|
+
|
|
485
473
|
|
|
486
474
|
DefaultSceneGraphService.prototype.getOrigin = function (element) {
|
|
487
475
|
return element.transformable.origin;
|
|
@@ -680,7 +668,7 @@ function () {
|
|
|
680
668
|
|
|
681
669
|
var bounds = this.getGeometryBounds(element, render);
|
|
682
670
|
|
|
683
|
-
if (bounds) {
|
|
671
|
+
if (!_shapes.AABB.isEmpty(bounds)) {
|
|
684
672
|
var aabb = new _shapes.AABB();
|
|
685
673
|
aabb.setFromTransformedAABB(bounds, this.getWorldTransform(element));
|
|
686
674
|
return aabb;
|
|
@@ -700,7 +688,7 @@ function () {
|
|
|
700
688
|
|
|
701
689
|
var geometry = element.geometry;
|
|
702
690
|
var bounds = render ? geometry.renderBounds : geometry.contentBounds || null;
|
|
703
|
-
return bounds && new _shapes.AABB(bounds.center, bounds.halfExtents) ||
|
|
691
|
+
return bounds && new _shapes.AABB(bounds.center, bounds.halfExtents) || new _shapes.AABB();
|
|
704
692
|
};
|
|
705
693
|
/**
|
|
706
694
|
* account for children in world space
|
|
@@ -774,7 +762,7 @@ function () {
|
|
|
774
762
|
renderable.boundsDirty = false;
|
|
775
763
|
}
|
|
776
764
|
|
|
777
|
-
return aabb ||
|
|
765
|
+
return aabb || new _shapes.AABB();
|
|
778
766
|
};
|
|
779
767
|
/**
|
|
780
768
|
* account for children in local space
|
|
@@ -791,7 +779,7 @@ function () {
|
|
|
791
779
|
|
|
792
780
|
var bounds = this.getBounds(element);
|
|
793
781
|
|
|
794
|
-
if (bounds) {
|
|
782
|
+
if (!_shapes.AABB.isEmpty(bounds)) {
|
|
795
783
|
var localBounds = new _shapes.AABB();
|
|
796
784
|
localBounds.setFromTransformedAABB(bounds, parentInvert);
|
|
797
785
|
return localBounds;
|
|
@@ -807,7 +795,7 @@ function () {
|
|
|
807
795
|
var aabb;
|
|
808
796
|
var bounds = this.getGeometryBounds(element);
|
|
809
797
|
|
|
810
|
-
if (bounds) {
|
|
798
|
+
if (!_shapes.AABB.isEmpty(bounds)) {
|
|
811
799
|
aabb = new _shapes.AABB(); // apply transformation to aabb
|
|
812
800
|
|
|
813
801
|
aabb.setFromTransformedAABB(bounds, this.getWorldTransform(element));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GeometryAABBUpdater } from './interfaces';
|
|
2
|
-
import type { ParsedCircleStyleProps } from '../../display-objects/Circle';
|
|
2
|
+
import type { Circle, ParsedCircleStyleProps } from '../../display-objects/Circle';
|
|
3
3
|
export declare class CircleUpdater implements GeometryAABBUpdater<ParsedCircleStyleProps> {
|
|
4
|
-
update(parsedStyle: ParsedCircleStyleProps): {
|
|
4
|
+
update(parsedStyle: ParsedCircleStyleProps, object: Circle): {
|
|
5
5
|
width: number;
|
|
6
6
|
height: number;
|
|
7
7
|
x: number;
|