@antv/g 5.0.14 → 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.js +1 -1
- package/es/dom/Element.d.ts +4 -4
- package/es/global-module.d.ts +3 -1
- package/es/global-module.js +28 -69
- 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 -7
- package/es/services/SceneGraphService.js +5 -5
- 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 +27 -14
- package/es/shapes/AABB.d.ts +1 -0
- package/es/shapes/AABB.js +8 -0
- package/es/types.d.ts +0 -2
- 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.js +1 -1
- package/lib/dom/Element.d.ts +4 -4
- package/lib/global-module.d.ts +3 -1
- package/lib/global-module.js +32 -69
- 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 -7
- package/lib/services/SceneGraphService.js +5 -5
- 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 +27 -14
- package/lib/shapes/AABB.d.ts +1 -0
- package/lib/shapes/AABB.js +8 -0
- package/lib/types.d.ts +0 -2
- package/lib/utils/path.d.ts +1 -1
- package/lib/utils/path.js +5 -5
- package/package.json +4 -4
|
@@ -8,18 +8,33 @@ var EllipseUpdater =
|
|
|
8
8
|
function () {
|
|
9
9
|
function EllipseUpdater() {}
|
|
10
10
|
|
|
11
|
-
EllipseUpdater.prototype.update = function (parsedStyle) {
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
EllipseUpdater.prototype.update = function (parsedStyle, object) {
|
|
12
|
+
var rx = parsedStyle.rx,
|
|
13
|
+
ry = parsedStyle.ry,
|
|
14
|
+
_a = parsedStyle.x,
|
|
15
|
+
x = _a === void 0 ? 0 : _a,
|
|
16
|
+
_b = parsedStyle.y,
|
|
17
|
+
y = _b === void 0 ? 0 : _b;
|
|
18
|
+
var rxUnit = rx.unit,
|
|
19
|
+
rxValue = rx.value;
|
|
20
|
+
var ryUnit = ry.unit,
|
|
21
|
+
ryValue = ry.value;
|
|
22
|
+
var width = 0;
|
|
23
|
+
var height = 0;
|
|
24
|
+
|
|
25
|
+
if (rxUnit === '' || rxUnit === 'px') {
|
|
26
|
+
width = rxValue * 2;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (ryUnit === '' || ryUnit === 'px') {
|
|
30
|
+
height = ryValue * 2;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
object.parsedStyle.rxInPixels = width / 2;
|
|
34
|
+
object.parsedStyle.ryInPixels = height / 2;
|
|
20
35
|
return {
|
|
21
|
-
width:
|
|
22
|
-
height:
|
|
36
|
+
width: width,
|
|
37
|
+
height: height,
|
|
23
38
|
x: x,
|
|
24
39
|
y: y
|
|
25
40
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GeometryAABBUpdater } from './interfaces';
|
|
2
|
-
import type { ParsedImageStyleProps } from '../../display-objects/Image';
|
|
2
|
+
import type { Image, ParsedImageStyleProps } from '../../display-objects/Image';
|
|
3
3
|
export declare class RectUpdater implements GeometryAABBUpdater<ParsedImageStyleProps> {
|
|
4
|
-
update(
|
|
4
|
+
update(parsedStyle: ParsedImageStyleProps, object: Image): {
|
|
5
5
|
width: number;
|
|
6
6
|
height: number;
|
|
7
7
|
x: number;
|
|
@@ -9,32 +9,45 @@ var RectUpdater =
|
|
|
9
9
|
function () {
|
|
10
10
|
function RectUpdater() {}
|
|
11
11
|
|
|
12
|
-
RectUpdater.prototype.update = function (
|
|
13
|
-
var img =
|
|
14
|
-
_a =
|
|
12
|
+
RectUpdater.prototype.update = function (parsedStyle, object) {
|
|
13
|
+
var img = parsedStyle.img,
|
|
14
|
+
_a = parsedStyle.x,
|
|
15
15
|
x = _a === void 0 ? 0 : _a,
|
|
16
|
-
_b =
|
|
16
|
+
_b = parsedStyle.y,
|
|
17
17
|
y = _b === void 0 ? 0 : _b,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
|
|
18
|
+
width = parsedStyle.width,
|
|
19
|
+
height = parsedStyle.height;
|
|
20
|
+
var contentWidth = 0;
|
|
21
|
+
var contentHeight = 0;
|
|
22
|
+
var widthUnit = width.unit,
|
|
23
|
+
widthValue = width.value;
|
|
24
|
+
var heightUnit = height.unit,
|
|
25
|
+
heightValue = height.value;
|
|
26
|
+
|
|
27
|
+
if (widthUnit === '' || widthUnit === 'px') {
|
|
28
|
+
contentWidth = widthValue;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (heightUnit === '' || heightUnit === 'px') {
|
|
32
|
+
contentHeight = heightValue;
|
|
33
|
+
} // resize with HTMLImageElement's size
|
|
34
|
+
|
|
24
35
|
|
|
25
36
|
if (img && !isString(img)) {
|
|
26
|
-
if (!
|
|
37
|
+
if (!contentWidth) {
|
|
27
38
|
contentWidth = img.width;
|
|
28
39
|
}
|
|
29
40
|
|
|
30
|
-
if (!
|
|
41
|
+
if (!contentHeight) {
|
|
31
42
|
contentHeight = img.height;
|
|
32
43
|
}
|
|
33
44
|
}
|
|
34
45
|
|
|
46
|
+
object.parsedStyle.widthInPixels = contentWidth;
|
|
47
|
+
object.parsedStyle.heightInPixels = contentHeight;
|
|
35
48
|
return {
|
|
36
|
-
width: contentWidth
|
|
37
|
-
height: contentHeight
|
|
49
|
+
width: contentWidth,
|
|
50
|
+
height: contentHeight,
|
|
38
51
|
x: x,
|
|
39
52
|
y: y
|
|
40
53
|
};
|
package/es/shapes/AABB.d.ts
CHANGED
package/es/shapes/AABB.js
CHANGED
|
@@ -14,6 +14,10 @@ function () {
|
|
|
14
14
|
this.update(center, halfExtents);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
AABB.isEmpty = function (aabb) {
|
|
18
|
+
return !aabb || aabb.halfExtents[0] === 0 && aabb.halfExtents[1] === 0 && aabb.halfExtents[2] === 0;
|
|
19
|
+
};
|
|
20
|
+
|
|
17
21
|
AABB.prototype.update = function (center, halfExtents) {
|
|
18
22
|
this.center = vec3.copy(vec3.create(), center || vec3.create());
|
|
19
23
|
this.halfExtents = vec3.copy(vec3.create(), halfExtents || vec3.fromValues(0, 0, 0));
|
|
@@ -39,6 +43,10 @@ function () {
|
|
|
39
43
|
};
|
|
40
44
|
|
|
41
45
|
AABB.prototype.add = function (aabb) {
|
|
46
|
+
if (AABB.isEmpty(aabb)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
42
50
|
var tc = this.center;
|
|
43
51
|
var tcx = tc[0];
|
|
44
52
|
var tcy = tc[1];
|
package/es/types.d.ts
CHANGED
|
@@ -134,8 +134,6 @@ export interface ParsedBaseStyleProps extends Omit<BaseStyleProps, 'fill' | 'str
|
|
|
134
134
|
points?: ParsedPolylineStyleProps;
|
|
135
135
|
x?: number;
|
|
136
136
|
y?: number;
|
|
137
|
-
width?: number;
|
|
138
|
-
height?: number;
|
|
139
137
|
/**
|
|
140
138
|
* x according to definition, eg. Line's x1/x2, Polyline's points
|
|
141
139
|
*/
|
package/es/utils/path.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare function getDrawDirection(pathArray: PathCommand[]): boolean;
|
|
|
5
5
|
export declare function getPathArea(pathArray: PathCommand[]): number;
|
|
6
6
|
export declare function reverseCurve(pathArray: PathCommand[]): PathCommand[];
|
|
7
7
|
export declare function clonePath(pathArray: PathCommand[]): PathCommand[];
|
|
8
|
-
export declare function getRotatedCurve(a: PathCommand[], b: PathCommand[]): (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] | ["
|
|
8
|
+
export declare function getRotatedCurve(a: PathCommand[], b: PathCommand[]): (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])[];
|
|
9
9
|
/**
|
|
10
10
|
* convert object to path, should account for:
|
|
11
11
|
* * transform & origin
|
package/es/utils/path.js
CHANGED
|
@@ -290,7 +290,7 @@ export function convertToPath(object) {
|
|
|
290
290
|
case SHAPE.Circle:
|
|
291
291
|
{
|
|
292
292
|
var _b = object.parsedStyle,
|
|
293
|
-
r = _b.
|
|
293
|
+
r = _b.rInPixels,
|
|
294
294
|
_c = _b.x,
|
|
295
295
|
x_1 = _c === void 0 ? 0 : _c,
|
|
296
296
|
_d = _b.y,
|
|
@@ -302,8 +302,8 @@ export function convertToPath(object) {
|
|
|
302
302
|
case SHAPE.Ellipse:
|
|
303
303
|
{
|
|
304
304
|
var _e = object.parsedStyle,
|
|
305
|
-
rx = _e.
|
|
306
|
-
ry = _e.
|
|
305
|
+
rx = _e.rxInPixels,
|
|
306
|
+
ry = _e.ryInPixels,
|
|
307
307
|
_f = _e.x,
|
|
308
308
|
x_2 = _f === void 0 ? 0 : _f,
|
|
309
309
|
_g = _e.y,
|
|
@@ -320,8 +320,8 @@ export function convertToPath(object) {
|
|
|
320
320
|
|
|
321
321
|
case SHAPE.Rect:
|
|
322
322
|
var _h = object.parsedStyle,
|
|
323
|
-
width = _h.
|
|
324
|
-
height = _h.
|
|
323
|
+
width = _h.widthInPixels,
|
|
324
|
+
height = _h.heightInPixels,
|
|
325
325
|
x = _h.x,
|
|
326
326
|
y = _h.y,
|
|
327
327
|
radius = _h.radius;
|
package/lib/Canvas.js
CHANGED
package/lib/canvas-module.js
CHANGED
|
@@ -19,22 +19,15 @@ var _services = require("./services");
|
|
|
19
19
|
|
|
20
20
|
var _EventPlugin = require("./plugins/EventPlugin");
|
|
21
21
|
|
|
22
|
-
var containerModule = (0, _manaSyringe.Module)(function (register
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}); // culling plugin
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
_manaSyringe.Contribution.register(register, _CullingPlugin.CullingStrategyContribution, {
|
|
35
|
-
cache: false
|
|
36
|
-
});
|
|
37
|
-
} // register built-in rendering plugins
|
|
22
|
+
var containerModule = (0, _manaSyringe.Module)(function (register) {
|
|
23
|
+
_manaSyringe.Contribution.register(register, _services.RenderingPluginContribution, {
|
|
24
|
+
cache: false
|
|
25
|
+
}); // culling plugin
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
_manaSyringe.Contribution.register(register, _CullingPlugin.CullingStrategyContribution, {
|
|
29
|
+
cache: false
|
|
30
|
+
}); // register built-in rendering plugins
|
|
38
31
|
|
|
39
32
|
|
|
40
33
|
register(_services.RenderingService);
|
|
@@ -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>);
|
|
@@ -247,7 +247,9 @@ function (_super) {
|
|
|
247
247
|
|
|
248
248
|
this.parseStyleProperty(name, value); // @ts-ignore
|
|
249
249
|
|
|
250
|
-
|
|
250
|
+
var newParsedValue = this.parsedStyle[name]; // @ts-ignore
|
|
251
|
+
|
|
252
|
+
this.updateStyleProperty(name, oldParsedValue, newParsedValue); // inform clip path targets
|
|
251
253
|
|
|
252
254
|
if (this.attributes.clipPathTargets && this.attributes.clipPathTargets.length) {
|
|
253
255
|
this.attributes.clipPathTargets.forEach(function (target) {
|
|
@@ -265,7 +267,9 @@ function (_super) {
|
|
|
265
267
|
this.emit(_interfaces.ElementEvent.ATTRIBUTE_CHANGED, {
|
|
266
268
|
attributeName: name,
|
|
267
269
|
oldValue: oldValue,
|
|
268
|
-
newValue: value
|
|
270
|
+
newValue: value,
|
|
271
|
+
oldParsedValue: oldParsedValue,
|
|
272
|
+
newParsedValue: newParsedValue
|
|
269
273
|
});
|
|
270
274
|
}; // #region transformable
|
|
271
275
|
|
|
@@ -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>);
|
|
@@ -25,7 +25,10 @@ function (_super) {
|
|
|
25
25
|
|
|
26
26
|
_this = _super.call(this, (0, _tslib.__assign)({
|
|
27
27
|
type: _types.SHAPE.Group,
|
|
28
|
-
style: (0, _tslib.__assign)({
|
|
28
|
+
style: (0, _tslib.__assign)({
|
|
29
|
+
width: 'auto',
|
|
30
|
+
height: 'auto'
|
|
31
|
+
}, style)
|
|
29
32
|
}, rest)) || this;
|
|
30
33
|
return _this;
|
|
31
34
|
}
|
|
@@ -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
|
}
|
|
@@ -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> {
|
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/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,77 +107,13 @@ 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);
|
|
@@ -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;
|