@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
package/es/Canvas.js
CHANGED
package/es/canvas-module.js
CHANGED
|
@@ -6,22 +6,14 @@ import { FrustumCullingStrategy } from './plugins/FrustumCullingStrategy';
|
|
|
6
6
|
import { RenderingPluginContribution, RenderingService } from './services';
|
|
7
7
|
import { EventPlugin } from './plugins/EventPlugin';
|
|
8
8
|
import { EventService } from './services';
|
|
9
|
-
export var containerModule = Module(function (register
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
context.container.remove(RenderingService);
|
|
14
|
-
context.container.remove(FrustumCullingStrategy);
|
|
15
|
-
} else {
|
|
16
|
-
Contribution.register(register, RenderingPluginContribution, {
|
|
17
|
-
cache: false
|
|
18
|
-
}); // culling plugin
|
|
19
|
-
|
|
20
|
-
Contribution.register(register, CullingStrategyContribution, {
|
|
21
|
-
cache: false
|
|
22
|
-
});
|
|
23
|
-
} // register built-in rendering plugins
|
|
9
|
+
export var containerModule = Module(function (register) {
|
|
10
|
+
Contribution.register(register, RenderingPluginContribution, {
|
|
11
|
+
cache: false
|
|
12
|
+
}); // culling plugin
|
|
24
13
|
|
|
14
|
+
Contribution.register(register, CullingStrategyContribution, {
|
|
15
|
+
cache: false
|
|
16
|
+
}); // register built-in rendering plugins
|
|
25
17
|
|
|
26
18
|
register(RenderingService);
|
|
27
19
|
register(EventService);
|
|
@@ -1,11 +1,13 @@
|
|
|
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
13
|
constructor({ style, ...rest }: DisplayObjectConfig<CircleStyleProps>);
|
|
@@ -228,7 +228,9 @@ function (_super) {
|
|
|
228
228
|
|
|
229
229
|
this.parseStyleProperty(name, value); // @ts-ignore
|
|
230
230
|
|
|
231
|
-
|
|
231
|
+
var newParsedValue = this.parsedStyle[name]; // @ts-ignore
|
|
232
|
+
|
|
233
|
+
this.updateStyleProperty(name, oldParsedValue, newParsedValue); // inform clip path targets
|
|
232
234
|
|
|
233
235
|
if (this.attributes.clipPathTargets && this.attributes.clipPathTargets.length) {
|
|
234
236
|
this.attributes.clipPathTargets.forEach(function (target) {
|
|
@@ -246,7 +248,9 @@ function (_super) {
|
|
|
246
248
|
this.emit(ElementEvent.ATTRIBUTE_CHANGED, {
|
|
247
249
|
attributeName: name,
|
|
248
250
|
oldValue: oldValue,
|
|
249
|
-
newValue: value
|
|
251
|
+
newValue: value,
|
|
252
|
+
oldParsedValue: oldParsedValue,
|
|
253
|
+
newParsedValue: newParsedValue
|
|
250
254
|
});
|
|
251
255
|
}; // #region transformable
|
|
252
256
|
|
|
@@ -1,13 +1,16 @@
|
|
|
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
16
|
constructor({ style, ...rest }: DisplayObjectConfig<EllipseStyleProps>);
|
|
@@ -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
|
}
|
|
@@ -77,7 +77,7 @@ function (_super) {
|
|
|
77
77
|
var parentInvert = mat4.invert(mat4.create(), this.parentNode.getWorldTransform());
|
|
78
78
|
var bounds = this.getBounds();
|
|
79
79
|
|
|
80
|
-
if (bounds) {
|
|
80
|
+
if (!AABB.isEmpty(bounds)) {
|
|
81
81
|
var localBounds = new AABB();
|
|
82
82
|
localBounds.setFromTransformedAABB(bounds, parentInvert);
|
|
83
83
|
return localBounds;
|
|
@@ -1,15 +1,18 @@
|
|
|
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
6
|
img: string | HTMLImageElement;
|
|
6
|
-
width?: number;
|
|
7
|
-
height?: number;
|
|
7
|
+
width?: number | string;
|
|
8
|
+
height?: number | string;
|
|
8
9
|
}
|
|
9
10
|
export interface ParsedImageStyleProps extends ParsedBaseStyleProps {
|
|
10
11
|
img: string | HTMLImageElement;
|
|
11
|
-
width?:
|
|
12
|
-
height?:
|
|
12
|
+
width?: ParsedElement;
|
|
13
|
+
height?: ParsedElement;
|
|
14
|
+
widthInPixels?: number;
|
|
15
|
+
heightInPixels?: number;
|
|
13
16
|
}
|
|
14
17
|
export declare class Image extends DisplayObject<ImageStyleProps, ParsedImageStyleProps> {
|
|
15
18
|
constructor({ style, ...rest }: DisplayObjectConfig<ImageStyleProps>);
|
|
@@ -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;
|
|
@@ -35,11 +35,11 @@ function (_super) {
|
|
|
35
35
|
lineCap: LINE_CAP.Butt,
|
|
36
36
|
lineWidth: 0,
|
|
37
37
|
miterLimit: 10,
|
|
38
|
-
padding: 0,
|
|
38
|
+
// padding: 0,
|
|
39
39
|
stroke: '#000',
|
|
40
40
|
whiteSpace: 'pre',
|
|
41
41
|
wordWrap: false,
|
|
42
|
-
wordWrapWidth:
|
|
42
|
+
wordWrapWidth: 0,
|
|
43
43
|
leading: 0
|
|
44
44
|
}, style)
|
|
45
45
|
}, rest)) || this;
|
package/es/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/es/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
|
}
|
|
@@ -34,6 +34,10 @@ function (_super) {
|
|
|
34
34
|
_this.isPrimary = false;
|
|
35
35
|
return _this;
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/getCoalescedEvents
|
|
39
|
+
*/
|
|
40
|
+
|
|
37
41
|
|
|
38
42
|
FederatedPointerEvent.prototype.getCoalescedEvents = function () {
|
|
39
43
|
if (this.type === 'pointermove' || this.type === 'mousemove' || this.type === 'touchmove') {
|
|
@@ -42,6 +46,10 @@ function (_super) {
|
|
|
42
46
|
|
|
43
47
|
return [];
|
|
44
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* @see https://chromestatus.com/feature/5765569655603200
|
|
51
|
+
*/
|
|
52
|
+
|
|
45
53
|
|
|
46
54
|
FederatedPointerEvent.prototype.getPredictedEvents = function () {
|
|
47
55
|
throw new Error('getPredictedEvents is not supported!');
|
package/es/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/es/global-module.js
CHANGED
|
@@ -7,6 +7,7 @@ import { TextService } from './services/text';
|
|
|
7
7
|
import { TextUpdater } from './services/aabb/TextUpdater';
|
|
8
8
|
import { OffscreenCanvasCreator } from './services/text/OffscreenCanvasCreator';
|
|
9
9
|
import { DefaultSceneGraphSelector, SceneGraphSelector, SceneGraphSelectorFactory } from './services/SceneGraphSelector';
|
|
10
|
+
import { parseLengthOrPercent, mergeDimensions } from './property-handlers';
|
|
10
11
|
import { // StylePropertyParserFactory,
|
|
11
12
|
// StylePropertyUpdaterFactory,
|
|
12
13
|
// StylePropertyMergerFactory,
|
|
@@ -15,6 +16,28 @@ export var globalContainer = GlobalContainer;
|
|
|
15
16
|
export var stylePropertyParserFactory = {};
|
|
16
17
|
export var stylePropertyUpdaterFactory = {};
|
|
17
18
|
export var stylePropertyMergerFactory = {};
|
|
19
|
+
export function addPropertyHandler(property, parser, merger, updater) {
|
|
20
|
+
if (parser) {
|
|
21
|
+
stylePropertyParserFactory[property] = parser; // register({ token: { token: StylePropertyParser, named: property }, useValue: parser });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (merger) {
|
|
25
|
+
stylePropertyMergerFactory[property] = merger; // register({ token: { token: StylePropertyMerger, named: property }, useValue: merger });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (updater) {
|
|
29
|
+
if (!stylePropertyUpdaterFactory[property]) {
|
|
30
|
+
stylePropertyUpdaterFactory[property] = [];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
stylePropertyUpdaterFactory[property].push(updater); // register({ token: { token: StylePropertyUpdater, named: property }, useValue: updater });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function addPropertiesHandler(properties, parser, merger, updater) {
|
|
37
|
+
for (var i = 0; i < properties.length; i++) {
|
|
38
|
+
addPropertyHandler(properties[i], parser, merger, updater);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
18
41
|
export var containerModule = Module(function (register) {
|
|
19
42
|
decorate(injectable(), EventEmitter); // bind DisplayObject pool
|
|
20
43
|
|
|
@@ -62,81 +85,18 @@ export var containerModule = Module(function (register) {
|
|
|
62
85
|
return cache[tagName];
|
|
63
86
|
};
|
|
64
87
|
}
|
|
65
|
-
}); //
|
|
66
|
-
// register({
|
|
67
|
-
// token: StylePropertyParserFactory,
|
|
68
|
-
// useFactory: (context) => {
|
|
69
|
-
// const cache = {};
|
|
70
|
-
// return (propertyName: string) => {
|
|
71
|
-
// if (!cache[propertyName]) {
|
|
72
|
-
// if (context.container.isBoundNamed(StylePropertyParser, propertyName)) {
|
|
73
|
-
// cache[propertyName] = context.container.getNamed(StylePropertyParser, propertyName);
|
|
74
|
-
// }
|
|
75
|
-
// }
|
|
76
|
-
// return cache[propertyName];
|
|
77
|
-
// };
|
|
78
|
-
// },
|
|
79
|
-
// });
|
|
80
|
-
// register({
|
|
81
|
-
// token: StylePropertyUpdaterFactory,
|
|
82
|
-
// useFactory: (context) => {
|
|
83
|
-
// const cache = {};
|
|
84
|
-
// return (propertyName: string) => {
|
|
85
|
-
// if (!cache[propertyName]) {
|
|
86
|
-
// if (context.container.isBoundNamed(StylePropertyUpdater, propertyName)) {
|
|
87
|
-
// cache[propertyName] = context.container.getAllNamed(StylePropertyUpdater, propertyName);
|
|
88
|
-
// }
|
|
89
|
-
// }
|
|
90
|
-
// return cache[propertyName];
|
|
91
|
-
// };
|
|
92
|
-
// },
|
|
93
|
-
// });
|
|
94
|
-
// register({
|
|
95
|
-
// token: StylePropertyMergerFactory,
|
|
96
|
-
// useFactory: (context) => {
|
|
97
|
-
// const cache = {};
|
|
98
|
-
// return (propertyName: string) => {
|
|
99
|
-
// if (!cache[propertyName]) {
|
|
100
|
-
// if (context.container.isBoundNamed(StylePropertyMerger, propertyName)) {
|
|
101
|
-
// cache[propertyName] = context.container.getNamed(StylePropertyMerger, propertyName);
|
|
102
|
-
// }
|
|
103
|
-
// }
|
|
104
|
-
// return cache[propertyName];
|
|
105
|
-
// };
|
|
106
|
-
// },
|
|
107
|
-
// });
|
|
108
|
-
|
|
109
|
-
function addPropertyHandler(property, parser, merger, updater) {
|
|
110
|
-
if (parser) {
|
|
111
|
-
stylePropertyParserFactory[property] = parser; // register({ token: { token: StylePropertyParser, named: property }, useValue: parser });
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (merger) {
|
|
115
|
-
stylePropertyMergerFactory[property] = merger; // register({ token: { token: StylePropertyMerger, named: property }, useValue: merger });
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (updater) {
|
|
119
|
-
if (!stylePropertyUpdaterFactory[property]) {
|
|
120
|
-
stylePropertyUpdaterFactory[property] = [];
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
stylePropertyUpdaterFactory[property].push(updater); // register({ token: { token: StylePropertyUpdater, named: property }, useValue: updater });
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function addPropertiesHandler(properties, parser, merger, updater) {
|
|
128
|
-
for (var i = 0; i < properties.length; i++) {
|
|
129
|
-
addPropertyHandler(properties[i], parser, merger, updater);
|
|
130
|
-
}
|
|
131
|
-
} // bind handlers for properties
|
|
132
|
-
|
|
88
|
+
}); // bind handlers for properties
|
|
133
89
|
|
|
134
90
|
addPropertiesHandler(['opacity', 'fillOpacity', 'strokeOpacity', 'offsetDistance'], parseNumber, clampedMergeNumbers(0, 1), undefined);
|
|
135
|
-
addPropertiesHandler(['
|
|
91
|
+
addPropertiesHandler(['lineWidth', 'shadowBlur'], parseNumber, clampedMergeNumbers(0, Infinity), undefined); // support percent
|
|
92
|
+
|
|
93
|
+
addPropertiesHandler(['r', 'rx', 'ry', 'width', 'height'], parseLengthOrPercent, // @ts-ignore
|
|
94
|
+
mergeDimensions, undefined);
|
|
136
95
|
addPropertiesHandler(['lineDash'], parseLineDash, // @ts-ignore
|
|
137
96
|
mergeNumberLists, undefined);
|
|
138
97
|
addPropertiesHandler(['x1', 'x2', 'y1', 'y2', 'lineDashOffset', 'shadowOffsetX', 'shadowOffsetY'], parseNumber, mergeNumbers, undefined);
|
|
139
|
-
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',
|
|
98
|
+
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',
|
|
99
|
+
'wordWrap', 'wordWrapWidth', 'leading', 'textBaseline', 'textAlign', 'whiteSpace'], undefined, undefined, updateGeometry);
|
|
140
100
|
addPropertiesHandler(['fill', 'stroke', 'shadowColor'], parseColor, mergeColors, undefined);
|
|
141
101
|
addPropertyHandler('clipPath', undefined, undefined, updateClipPath);
|
|
142
102
|
addPropertyHandler('zIndex', undefined, undefined, updateZIndex);
|
|
@@ -35,11 +35,10 @@ export function updateGeometry(oldValue, newValue, object) {
|
|
|
35
35
|
_g = _a.offsetY,
|
|
36
36
|
offsetY = _g === void 0 ? 0 : _g,
|
|
37
37
|
_h = _a.offsetZ,
|
|
38
|
-
offsetZ = _h === void 0 ? 0 : _h;
|
|
38
|
+
offsetZ = _h === void 0 ? 0 : _h; // object.parsedStyle.width = width;
|
|
39
|
+
// object.parsedStyle.height = height;
|
|
40
|
+
// object.parsedStyle.depth = depth;
|
|
39
41
|
|
|
40
|
-
object.parsedStyle.width = width;
|
|
41
|
-
object.parsedStyle.height = height;
|
|
42
|
-
object.parsedStyle.depth = depth;
|
|
43
42
|
|
|
44
43
|
if (object.nodeName === SHAPE.Line || object.nodeName === SHAPE.Polyline || object.nodeName === SHAPE.Polygon || object.nodeName === SHAPE.Path) {
|
|
45
44
|
object.parsedStyle.offsetX = x - (object.parsedStyle.defX || 0);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { __read, __spreadArray } from "tslib";
|
|
2
2
|
import { vec3 } from 'gl-matrix';
|
|
3
3
|
import { dirtifyToRoot } from '../services';
|
|
4
|
+
import { AABB } from '../shapes';
|
|
4
5
|
import { createVec3 } from '../utils';
|
|
5
6
|
export function updateAnchor(oldValue, newValue, object) {
|
|
6
7
|
var bounds = object.getGeometryBounds();
|
|
7
8
|
|
|
8
|
-
if (bounds) {
|
|
9
|
+
if (!AABB.isEmpty(bounds)) {
|
|
9
10
|
var geometry = object.geometry;
|
|
10
11
|
|
|
11
12
|
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;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { numberToString } from './numeric';
|
|
2
2
|
import { rad2deg } from '../utils/math';
|
|
3
3
|
import { isFinite } from '@antv/util';
|
|
4
|
+
import { AABB } from '../shapes';
|
|
4
5
|
|
|
5
6
|
function isLengthUnit(unit) {
|
|
6
7
|
return unit === 'px' || unit === '%';
|
|
@@ -11,7 +12,7 @@ function isAngleUnit(unit) {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export function parseDimension(unitRegExp, string) {
|
|
14
|
-
string = string.trim().toLowerCase();
|
|
15
|
+
string = ("" + string).trim().toLowerCase();
|
|
15
16
|
|
|
16
17
|
if (string === '0') {
|
|
17
18
|
if ('px'.search(unitRegExp) >= 0) {
|
|
@@ -27,6 +28,11 @@ export function parseDimension(unitRegExp, string) {
|
|
|
27
28
|
value: 0
|
|
28
29
|
};
|
|
29
30
|
}
|
|
31
|
+
} else if (string === 'auto') {
|
|
32
|
+
return {
|
|
33
|
+
unit: 'auto',
|
|
34
|
+
value: 0
|
|
35
|
+
};
|
|
30
36
|
}
|
|
31
37
|
|
|
32
38
|
if (isFinite(Number(string))) {
|
|
@@ -91,6 +97,28 @@ var lengthUnits = 'px';
|
|
|
91
97
|
export var parseLength = parseDimension.bind(null, new RegExp(lengthUnits, 'g'));
|
|
92
98
|
export var parseLengthOrPercent = parseDimension.bind(null, new RegExp(lengthUnits + '|%', 'g'));
|
|
93
99
|
export var parseAngle = parseDimension.bind(null, /deg|rad|grad|turn/g);
|
|
100
|
+
export function parseLengthOrPercentList(list) {
|
|
101
|
+
return list.map(parseLengthOrPercent);
|
|
102
|
+
} // export function mergeDimensionsLists(
|
|
103
|
+
// left: ParsedElement[],
|
|
104
|
+
// right: ParsedElement[],
|
|
105
|
+
// target: DisplayObject | null,
|
|
106
|
+
// ): [ParsedElement[], ParsedElement[], (list: ParsedElement[]) => string] | undefined {
|
|
107
|
+
// if (left.length != right.length) {
|
|
108
|
+
// return;
|
|
109
|
+
// }
|
|
110
|
+
// return [
|
|
111
|
+
// leftValue,
|
|
112
|
+
// rightValue,
|
|
113
|
+
// (value: number) => {
|
|
114
|
+
// if (nonNegative) {
|
|
115
|
+
// value = Math.max(value, 0);
|
|
116
|
+
// }
|
|
117
|
+
// return numberToString(value) + unit;
|
|
118
|
+
// },
|
|
119
|
+
// ];
|
|
120
|
+
// }
|
|
121
|
+
|
|
94
122
|
export function convertPercentUnit(valueWithUnit, vec3Index, target) {
|
|
95
123
|
if (valueWithUnit.unit === 'px') {
|
|
96
124
|
return Number(valueWithUnit.value);
|
|
@@ -99,7 +127,7 @@ export function convertPercentUnit(valueWithUnit, vec3Index, target) {
|
|
|
99
127
|
var bounds = target.getBounds();
|
|
100
128
|
var size = 0;
|
|
101
129
|
|
|
102
|
-
if (bounds) {
|
|
130
|
+
if (!AABB.isEmpty(bounds)) {
|
|
103
131
|
size = bounds.halfExtents[vec3Index] * 2;
|
|
104
132
|
}
|
|
105
133
|
|
|
@@ -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;
|