@antv/g 5.0.22 → 5.0.23-alpha.0
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 +3 -3
- package/es/AbstractRenderer.js +5 -0
- package/es/camera/Camera.js +2 -2
- package/es/css/parser/color.js +1 -1
- package/es/css/parser/dimension.js +1 -2
- package/es/css/parser/numeric.js +1 -1
- package/es/css/parser/path.d.ts +2 -2
- package/es/css/parser/path.js +1 -1
- package/es/css/parser/points.js +1 -1
- package/es/css/parser/transform-origin.js +1 -1
- package/es/css/properties/CSSPropertyPath.d.ts +14 -2
- package/es/css/properties/CSSPropertyTextTransform.d.ts +2 -2
- package/es/css/properties/CSSPropertyTransform.js +1 -2
- package/es/display-objects/DisplayObject.js +4 -5
- package/es/display-objects/Path.d.ts +15 -15
- package/es/display-objects/Path.js +1 -1
- package/es/display-objects/Polygon.d.ts +8 -1
- package/es/display-objects/Polyline.d.ts +7 -5
- package/es/dom/Document.js +2 -2
- package/es/dom/Element.js +1 -2
- package/es/dom/EventTarget.js +1 -1
- package/es/dom/FederatedTouchEvent.d.ts +5 -3
- package/es/plugins/CullingPlugin.d.ts +0 -1
- package/es/plugins/CullingPlugin.js +3 -8
- package/es/plugins/DirtyCheckPlugin.d.ts +1 -1
- package/es/plugins/DirtyCheckPlugin.js +9 -8
- package/es/plugins/EventPlugin.d.ts +1 -1
- package/es/plugins/EventPlugin.js +163 -148
- package/es/plugins/PrepareRendererPlugin.d.ts +0 -1
- package/es/plugins/PrepareRendererPlugin.js +15 -16
- package/es/services/EventService.d.ts +8 -0
- package/es/services/EventService.js +274 -20
- package/es/services/RenderingService.d.ts +17 -16
- package/es/services/RenderingService.js +18 -17
- package/es/services/SceneGraphService.js +1 -1
- package/es/services/aabb/PathUpdater.d.ts +3 -3
- package/es/services/aabb/PolylineUpdater.d.ts +3 -3
- package/es/services/aabb/RectUpdater.js +1 -1
- package/es/types.d.ts +5 -3
- package/es/utils/assert.d.ts +6 -0
- package/es/utils/assert.js +18 -0
- package/es/utils/event.d.ts +18 -16
- package/es/utils/hooks.d.ts +280 -0
- package/es/utils/hooks.js +753 -0
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +2 -1
- package/es/utils/math.d.ts +1 -0
- package/es/utils/math.js +13 -2
- package/es/utils/string.d.ts +1 -0
- package/es/utils/string.js +8 -0
- package/es/utils/text.js +2 -1
- package/lib/AbstractRenderer.js +5 -0
- package/lib/camera/Camera.js +4 -4
- package/lib/css/parser/color.js +5 -5
- package/lib/css/parser/dimension.js +1 -3
- package/lib/css/parser/numeric.js +3 -3
- package/lib/css/parser/path.d.ts +2 -2
- package/lib/css/parser/path.js +4 -4
- package/lib/css/parser/points.js +2 -2
- package/lib/css/parser/transform-origin.js +2 -2
- package/lib/css/properties/CSSPropertyPath.d.ts +14 -2
- package/lib/css/properties/CSSPropertyTextTransform.d.ts +2 -2
- package/lib/css/properties/CSSPropertyTransform.js +0 -2
- package/lib/display-objects/DisplayObject.js +7 -9
- package/lib/display-objects/Path.d.ts +15 -15
- package/lib/display-objects/Path.js +3 -3
- package/lib/display-objects/Polygon.d.ts +8 -1
- package/lib/display-objects/Polyline.d.ts +7 -5
- package/lib/dom/Document.js +2 -2
- package/lib/dom/Element.js +1 -3
- package/lib/dom/EventTarget.js +9 -9
- package/lib/dom/FederatedTouchEvent.d.ts +5 -3
- package/lib/plugins/CullingPlugin.d.ts +0 -1
- package/lib/plugins/CullingPlugin.js +3 -7
- package/lib/plugins/DirtyCheckPlugin.d.ts +1 -1
- package/lib/plugins/DirtyCheckPlugin.js +10 -8
- package/lib/plugins/EventPlugin.d.ts +1 -1
- package/lib/plugins/EventPlugin.js +172 -156
- package/lib/plugins/PrepareRendererPlugin.d.ts +0 -1
- package/lib/plugins/PrepareRendererPlugin.js +14 -14
- package/lib/services/EventService.d.ts +8 -0
- package/lib/services/EventService.js +274 -19
- package/lib/services/RenderingService.d.ts +17 -16
- package/lib/services/RenderingService.js +19 -18
- package/lib/services/SceneGraphService.js +3 -3
- package/lib/services/aabb/PathUpdater.d.ts +3 -3
- package/lib/services/aabb/PolylineUpdater.d.ts +3 -3
- package/lib/services/aabb/RectUpdater.js +3 -3
- package/lib/types.d.ts +5 -3
- package/lib/utils/assert.d.ts +6 -0
- package/lib/utils/assert.js +30 -0
- package/lib/utils/event.d.ts +18 -16
- package/lib/utils/hooks.d.ts +280 -0
- package/lib/utils/hooks.js +759 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +13 -0
- package/lib/utils/math.d.ts +1 -0
- package/lib/utils/math.js +17 -4
- package/lib/utils/string.d.ts +1 -0
- package/lib/utils/string.js +11 -0
- package/lib/utils/text.js +5 -3
- package/package.json +4 -7
package/es/utils/index.d.ts
CHANGED
package/es/utils/index.js
CHANGED
package/es/utils/math.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { quat, vec2, vec4 } from 'gl-matrix';
|
|
2
2
|
import { mat3, mat4, vec3 } from 'gl-matrix';
|
|
3
|
+
export declare function clamp(number: number, boundOne: number, boundTwo: number): number;
|
|
3
4
|
export declare function getAngle(angle?: number): number;
|
|
4
5
|
export declare function createVec3(x: number | vec2 | vec3 | vec4, y?: number, z?: number): vec3;
|
|
5
6
|
export declare function deg2rad(deg: number): number;
|
package/es/utils/math.js
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { __read } from "tslib";
|
|
2
|
-
import { isArray, isNumber } from 'lodash-es';
|
|
3
2
|
import { mat3, mat4, vec3 } from 'gl-matrix';
|
|
3
|
+
import { isNumber } from './assert';
|
|
4
|
+
export function clamp(number, boundOne, boundTwo) {
|
|
5
|
+
if (!boundTwo) {
|
|
6
|
+
return Math.max(number, boundOne) === boundOne ? number : boundOne;
|
|
7
|
+
} else if (Math.min(number, boundOne) === number) {
|
|
8
|
+
return boundOne;
|
|
9
|
+
} else if (Math.max(number, boundTwo) === number) {
|
|
10
|
+
return boundTwo;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return number;
|
|
14
|
+
}
|
|
4
15
|
export function getAngle(angle) {
|
|
5
16
|
if (angle === undefined) {
|
|
6
17
|
return 0;
|
|
@@ -23,7 +34,7 @@ export function createVec3(x, y, z) {
|
|
|
23
34
|
return vec3.fromValues(x, y, z);
|
|
24
35
|
}
|
|
25
36
|
|
|
26
|
-
if (isArray(x) && x.length === 3) {
|
|
37
|
+
if (Array.isArray(x) && x.length === 3) {
|
|
27
38
|
return vec3.clone(x);
|
|
28
39
|
}
|
|
29
40
|
|
package/es/utils/string.d.ts
CHANGED
package/es/utils/string.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isNil } from './assert';
|
|
1
2
|
export function camelCase(str) {
|
|
2
3
|
if (str === void 0) {
|
|
3
4
|
str = '';
|
|
@@ -6,4 +7,11 @@ export function camelCase(str) {
|
|
|
6
7
|
return str.replace(/-([a-z])/g, function (g) {
|
|
7
8
|
return g[1].toUpperCase();
|
|
8
9
|
});
|
|
10
|
+
}
|
|
11
|
+
export function isString(str) {
|
|
12
|
+
if (!isNil(str) && typeof str === 'string') {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return false;
|
|
9
17
|
}
|
package/es/utils/text.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { isNumber
|
|
1
|
+
import { isNumber } from './assert';
|
|
2
|
+
import { isString } from './string';
|
|
2
3
|
var genericFontFamilies = ['serif', 'sans-serif', 'monospace', 'cursive', 'fantasy', 'system-ui'];
|
|
3
4
|
export function toFontString(attributes) {
|
|
4
5
|
var fontSize = attributes.fontSize,
|
package/lib/AbstractRenderer.js
CHANGED
package/lib/camera/Camera.js
CHANGED
|
@@ -7,8 +7,6 @@ exports.DefaultCamera = exports.CameraType = exports.CameraTrackingMode = export
|
|
|
7
7
|
|
|
8
8
|
var _tslib = require("tslib");
|
|
9
9
|
|
|
10
|
-
var _lodashEs = require("lodash-es");
|
|
11
|
-
|
|
12
10
|
var _manaSyringe = require("mana-syringe");
|
|
13
11
|
|
|
14
12
|
var _eventemitter = require("eventemitter3");
|
|
@@ -21,6 +19,8 @@ var _math = require("../utils/math");
|
|
|
21
19
|
|
|
22
20
|
var _animation = require("../utils/animation");
|
|
23
21
|
|
|
22
|
+
var _utils = require("../utils");
|
|
23
|
+
|
|
24
24
|
// import { DisplayObject } from '../display-objects';
|
|
25
25
|
var DefaultCamera = _manaSyringe.Syringe.defineToken('DefaultCamera');
|
|
26
26
|
|
|
@@ -914,12 +914,12 @@ function (_super) {
|
|
|
914
914
|
options = {};
|
|
915
915
|
}
|
|
916
916
|
|
|
917
|
-
var landmark = (0,
|
|
917
|
+
var landmark = (0, _utils.isString)(name) ? this.landmarks.find(function (l) {
|
|
918
918
|
return l.name === name;
|
|
919
919
|
}) : name;
|
|
920
920
|
|
|
921
921
|
if (landmark) {
|
|
922
|
-
var _a = (0,
|
|
922
|
+
var _a = (0, _utils.isNumber)(options) ? {
|
|
923
923
|
duration: options
|
|
924
924
|
} : options,
|
|
925
925
|
_b = _a.easing,
|
package/lib/css/parser/color.js
CHANGED
|
@@ -12,10 +12,10 @@ var _tslib = require("tslib");
|
|
|
12
12
|
|
|
13
13
|
var d3 = _interopRequireWildcard(require("d3-color"));
|
|
14
14
|
|
|
15
|
-
var _lodashEs = require("lodash-es");
|
|
16
|
-
|
|
17
15
|
var _cssom = require("../cssom");
|
|
18
16
|
|
|
17
|
+
var _utils = require("../../utils");
|
|
18
|
+
|
|
19
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
20
20
|
|
|
21
21
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -54,7 +54,7 @@ function parseColor(colorStr) {
|
|
|
54
54
|
var parsedRadialGradient = parseRadialGradient(colorStr);
|
|
55
55
|
|
|
56
56
|
if (parsedRadialGradient) {
|
|
57
|
-
if ((0,
|
|
57
|
+
if ((0, _utils.isString)(parsedRadialGradient)) {
|
|
58
58
|
colorStr = parsedRadialGradient;
|
|
59
59
|
} else {
|
|
60
60
|
return new _cssom.CSSGradientValue(_cssom.GradientPatternType.RadialGradient, parsedRadialGradient);
|
|
@@ -102,11 +102,11 @@ function mergeColors(left, right) {
|
|
|
102
102
|
|
|
103
103
|
if (rgba[3]) {
|
|
104
104
|
for (var i = 0; i < 3; i++) {
|
|
105
|
-
rgba[i] = Math.round((0,
|
|
105
|
+
rgba[i] = Math.round((0, _utils.clamp)(rgba[i], 0, 255));
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
rgba[3] = (0,
|
|
109
|
+
rgba[3] = (0, _utils.clamp)(rgba[3], 0, 1);
|
|
110
110
|
return "rgba(".concat(rgba.join(','), ")");
|
|
111
111
|
}];
|
|
112
112
|
}
|
|
@@ -12,8 +12,6 @@ exports.parseDimension = parseDimension;
|
|
|
12
12
|
exports.parseDimensionArray = parseDimensionArray;
|
|
13
13
|
exports.parserPercentage = exports.parseLengthOrPercentage = exports.parseLength = void 0;
|
|
14
14
|
|
|
15
|
-
var _lodashEs = require("lodash-es");
|
|
16
|
-
|
|
17
15
|
var _shapes = require("../../shapes");
|
|
18
16
|
|
|
19
17
|
var _utils = require("../../utils");
|
|
@@ -124,7 +122,7 @@ function convertAngleUnit(value) {
|
|
|
124
122
|
}
|
|
125
123
|
|
|
126
124
|
function parseDimensionArray(string) {
|
|
127
|
-
if ((0,
|
|
125
|
+
if ((0, _utils.isString)(string)) {
|
|
128
126
|
// "1px 2px 3px"
|
|
129
127
|
return string.split(' ').map(function (segment) {
|
|
130
128
|
return parseLengthOrPercentage(segment);
|
|
@@ -10,7 +10,7 @@ exports.numberToString = numberToString;
|
|
|
10
10
|
exports.parseNumber = parseNumber;
|
|
11
11
|
exports.parseNumberList = parseNumberList;
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _utils = require("../../utils");
|
|
14
14
|
|
|
15
15
|
var _cssom = require("../cssom");
|
|
16
16
|
|
|
@@ -47,7 +47,7 @@ function parseNumber(string) {
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
function parseNumberList(string) {
|
|
50
|
-
if ((0,
|
|
50
|
+
if ((0, _utils.isString)(string)) {
|
|
51
51
|
return string.split(' ').map(parseNumber);
|
|
52
52
|
} else {
|
|
53
53
|
return string.map(parseNumber);
|
|
@@ -61,7 +61,7 @@ function mergeNumbers(left, right) {
|
|
|
61
61
|
function clampedMergeNumbers(min, max) {
|
|
62
62
|
return function (left, right) {
|
|
63
63
|
return [left.value, right.value, function (x) {
|
|
64
|
-
return numberToString((0,
|
|
64
|
+
return numberToString((0, _utils.clamp)(x, min, max));
|
|
65
65
|
}];
|
|
66
66
|
};
|
|
67
67
|
}
|
package/lib/css/parser/path.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PathCommand } from '../../types';
|
|
2
2
|
import type { ParsedPathStyleProps } from '../../display-objects';
|
|
3
3
|
import type { IElement } from '../../dom';
|
|
4
|
-
export declare function parsePath(path: string): ParsedPathStyleProps;
|
|
5
|
-
export declare function mergePaths(left: ParsedPathStyleProps, right: ParsedPathStyleProps, object: IElement): [PathCommand[], PathCommand[], (b: PathCommand[]) => PathCommand[]];
|
|
4
|
+
export declare function parsePath(path: string): ParsedPathStyleProps['path'];
|
|
5
|
+
export declare function mergePaths(left: ParsedPathStyleProps['path'], right: ParsedPathStyleProps['path'], object: IElement): [PathCommand[], PathCommand[], (b: PathCommand[]) => PathCommand[]];
|
package/lib/css/parser/path.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.parsePath = parsePath;
|
|
|
8
8
|
|
|
9
9
|
var _tslib = require("tslib");
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _util = require("@antv/util");
|
|
12
12
|
|
|
13
13
|
var _gMath = require("@antv/g-math");
|
|
14
14
|
|
|
@@ -17,7 +17,7 @@ var _path = require("../../utils/path");
|
|
|
17
17
|
var _Rectangle = require("../../shapes/Rectangle");
|
|
18
18
|
|
|
19
19
|
function parsePath(path) {
|
|
20
|
-
var absolutePath = (0,
|
|
20
|
+
var absolutePath = (0, _util.path2Absolute)(path);
|
|
21
21
|
var hasArc = hasArcOrBezier(absolutePath);
|
|
22
22
|
var clonedAbsolutePath = absolutePath.slice();
|
|
23
23
|
|
|
@@ -27,11 +27,11 @@ function parsePath(path) {
|
|
|
27
27
|
// @see http://thednp.github.io/kute.js/svgCubicMorph.html
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
var _b = (0, _tslib.__read)((0,
|
|
30
|
+
var _b = (0, _tslib.__read)((0, _util.path2Curve)(clonedAbsolutePath, true), 2),
|
|
31
31
|
curve = _b[0],
|
|
32
32
|
zCommandIndexes = _b[1];
|
|
33
33
|
|
|
34
|
-
var segments = (0,
|
|
34
|
+
var segments = (0, _util.path2Segments)(clonedAbsolutePath);
|
|
35
35
|
|
|
36
36
|
var _c = calcLength(curve),
|
|
37
37
|
totalLength = _c.totalLength,
|
package/lib/css/parser/points.js
CHANGED
|
@@ -7,10 +7,10 @@ exports.parsePoints = parsePoints;
|
|
|
7
7
|
|
|
8
8
|
var _gMath = require("@antv/g-math");
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _utils = require("../../utils");
|
|
11
11
|
|
|
12
12
|
function parsePoints(points) {
|
|
13
|
-
if ((0,
|
|
13
|
+
if ((0, _utils.isString)(points)) {
|
|
14
14
|
return null;
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.parseTransformOrigin = parseTransformOrigin;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _utils = require("../../utils");
|
|
9
9
|
|
|
10
10
|
var _cssom = require("../cssom");
|
|
11
11
|
|
|
@@ -16,7 +16,7 @@ var _dimension = require("./dimension");
|
|
|
16
16
|
* eg. 'center' 'top left' '50px 50px'
|
|
17
17
|
*/
|
|
18
18
|
function parseTransformOrigin(value) {
|
|
19
|
-
if ((0,
|
|
19
|
+
if ((0, _utils.isString)(value)) {
|
|
20
20
|
var values = value.split(' ');
|
|
21
21
|
|
|
22
22
|
if (values.length === 1) {
|
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import type { DisplayObject, ParsedPathStyleProps } from '../../display-objects';
|
|
2
|
+
import { Rectangle } from '../../shapes';
|
|
2
3
|
import type { CSSProperty } from '../CSSProperty';
|
|
3
4
|
import { parsePath, mergePaths } from '../parser';
|
|
4
|
-
export declare class CSSPropertyPath implements Partial<CSSProperty<ParsedPathStyleProps, ParsedPathStyleProps>> {
|
|
5
|
+
export declare class CSSPropertyPath implements Partial<CSSProperty<ParsedPathStyleProps['path'], ParsedPathStyleProps['path']>> {
|
|
5
6
|
/**
|
|
6
7
|
* path2Curve
|
|
7
8
|
*/
|
|
8
9
|
parser: typeof parsePath;
|
|
9
|
-
calculator(name: string, oldParsed: ParsedPathStyleProps, parsed: ParsedPathStyleProps):
|
|
10
|
+
calculator(name: string, oldParsed: ParsedPathStyleProps['path'], parsed: ParsedPathStyleProps['path']): {
|
|
11
|
+
absolutePath: import("../../types").PathCommand[];
|
|
12
|
+
hasArc: boolean;
|
|
13
|
+
segments: import("../../display-objects").PathSegment[];
|
|
14
|
+
polygons: [number, number][][];
|
|
15
|
+
polylines: [number, number][][];
|
|
16
|
+
curve: import("../../types").PathCommand[];
|
|
17
|
+
totalLength: number;
|
|
18
|
+
curveSegments: number[][];
|
|
19
|
+
zCommandIndexes: number[];
|
|
20
|
+
rect: Rectangle;
|
|
21
|
+
};
|
|
10
22
|
mixer: typeof mergePaths;
|
|
11
23
|
/**
|
|
12
24
|
* update local position
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CSSProperty } from '../CSSProperty';
|
|
2
|
-
import type { DisplayObject
|
|
3
|
-
export declare class CSSPropertyTextTransform implements Partial<CSSProperty<
|
|
2
|
+
import type { DisplayObject } from '../../display-objects';
|
|
3
|
+
export declare class CSSPropertyTextTransform implements Partial<CSSProperty<any, any>> {
|
|
4
4
|
postProcessor(o: DisplayObject): void;
|
|
5
5
|
}
|
|
@@ -9,8 +9,6 @@ var _tslib = require("tslib");
|
|
|
9
9
|
|
|
10
10
|
var _manaSyringe = require("mana-syringe");
|
|
11
11
|
|
|
12
|
-
var _lodashEs = require("lodash-es");
|
|
13
|
-
|
|
14
12
|
var _glMatrix = require("gl-matrix");
|
|
15
13
|
|
|
16
14
|
var _DisplayObjectPool = require("../DisplayObjectPool");
|
|
@@ -115,11 +113,11 @@ function (_super) {
|
|
|
115
113
|
interactive: (_c = _this.config.interactive) !== null && _c !== void 0 ? _c : true
|
|
116
114
|
}), _this.config.style), _this.config.attrs);
|
|
117
115
|
|
|
118
|
-
if (
|
|
116
|
+
if (_this.config.visible != null) {
|
|
119
117
|
_this.config.style.visibility = _this.config.visible === false ? 'hidden' : 'visible';
|
|
120
118
|
}
|
|
121
119
|
|
|
122
|
-
if (
|
|
120
|
+
if (_this.config.interactive != null) {
|
|
123
121
|
_this.config.style.pointerEvents = _this.config.interactive === false ? 'none' : 'auto';
|
|
124
122
|
}
|
|
125
123
|
|
|
@@ -213,11 +211,11 @@ function (_super) {
|
|
|
213
211
|
attributeValue = _a[1]; // ignore undefined value
|
|
214
212
|
|
|
215
213
|
|
|
216
|
-
if ((0,
|
|
214
|
+
if ((0, _utils.isUndefined)(value)) {
|
|
217
215
|
return;
|
|
218
216
|
}
|
|
219
217
|
|
|
220
|
-
if (force ||
|
|
218
|
+
if (force || attributeValue != this.attributes[attributeName]) {
|
|
221
219
|
this.internalSetAttribute(attributeName, attributeValue);
|
|
222
220
|
|
|
223
221
|
_super.prototype.setAttribute.call(this, attributeName, attributeValue);
|
|
@@ -476,7 +474,7 @@ function (_super) {
|
|
|
476
474
|
};
|
|
477
475
|
|
|
478
476
|
DisplayObject.prototype.rotateLocal = function (x, y, z) {
|
|
479
|
-
if ((0,
|
|
477
|
+
if ((0, _utils.isNil)(y) && (0, _utils.isNil)(z)) {
|
|
480
478
|
this.sceneGraphService.rotateLocal(this, 0, 0, x);
|
|
481
479
|
} else {
|
|
482
480
|
this.sceneGraphService.rotateLocal(this, x, y, z);
|
|
@@ -486,7 +484,7 @@ function (_super) {
|
|
|
486
484
|
};
|
|
487
485
|
|
|
488
486
|
DisplayObject.prototype.rotate = function (x, y, z) {
|
|
489
|
-
if ((0,
|
|
487
|
+
if ((0, _utils.isNil)(y) && (0, _utils.isNil)(z)) {
|
|
490
488
|
this.sceneGraphService.rotate(this, 0, 0, x);
|
|
491
489
|
} else {
|
|
492
490
|
this.sceneGraphService.rotate(this, x, y, z);
|
|
@@ -796,7 +794,7 @@ function (_super) {
|
|
|
796
794
|
return this.attributes;
|
|
797
795
|
}
|
|
798
796
|
|
|
799
|
-
if ((0,
|
|
797
|
+
if ((0, _utils.isObject)(name)) {
|
|
800
798
|
Object.keys(name).forEach(function (key) {
|
|
801
799
|
_this.setAttribute(key, name[key]);
|
|
802
800
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BaseStyleProps, PathCommand } from '../types';
|
|
1
|
+
import type { BaseStyleProps, PathCommand, ParsedBaseStyleProps } from '../types';
|
|
2
2
|
import { DisplayObject } from './DisplayObject';
|
|
3
3
|
import type { DisplayObjectConfig } from '../dom';
|
|
4
4
|
import { Point } from '../shapes';
|
|
@@ -16,21 +16,21 @@ export interface PathSegment {
|
|
|
16
16
|
endTangent: [number, number] | null;
|
|
17
17
|
params: PathCommand;
|
|
18
18
|
}
|
|
19
|
-
export interface ParsedPathStyleProps {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
export interface ParsedPathStyleProps extends ParsedBaseStyleProps {
|
|
20
|
+
path: {
|
|
21
|
+
absolutePath: PathCommand[];
|
|
22
|
+
hasArc: boolean;
|
|
23
|
+
segments: PathSegment[];
|
|
24
|
+
polygons: [number, number][][];
|
|
25
|
+
polylines: [number, number][][];
|
|
26
|
+
curve: PathCommand[];
|
|
27
|
+
totalLength: number;
|
|
28
|
+
curveSegments: number[][];
|
|
29
|
+
zCommandIndexes: number[];
|
|
30
|
+
rect: Rectangle;
|
|
31
|
+
};
|
|
30
32
|
}
|
|
31
|
-
export declare class Path extends DisplayObject<PathStyleProps, {
|
|
32
|
-
path: ParsedPathStyleProps;
|
|
33
|
-
}> {
|
|
33
|
+
export declare class Path extends DisplayObject<PathStyleProps, ParsedPathStyleProps> {
|
|
34
34
|
constructor({ style, ...rest }?: DisplayObjectConfig<PathStyleProps>);
|
|
35
35
|
getTotalLength(): number;
|
|
36
36
|
/**
|
|
@@ -9,14 +9,14 @@ var _tslib = require("tslib");
|
|
|
9
9
|
|
|
10
10
|
var _gMath = require("@antv/g-math");
|
|
11
11
|
|
|
12
|
-
var _lodashEs = require("lodash-es");
|
|
13
|
-
|
|
14
12
|
var _types = require("../types");
|
|
15
13
|
|
|
16
14
|
var _DisplayObject = require("./DisplayObject");
|
|
17
15
|
|
|
18
16
|
var _shapes = require("../shapes");
|
|
19
17
|
|
|
18
|
+
var _utils = require("../utils");
|
|
19
|
+
|
|
20
20
|
var Path =
|
|
21
21
|
/** @class */
|
|
22
22
|
function (_super) {
|
|
@@ -68,7 +68,7 @@ function (_super) {
|
|
|
68
68
|
});
|
|
69
69
|
var seg = curve[index];
|
|
70
70
|
|
|
71
|
-
if ((0,
|
|
71
|
+
if ((0, _utils.isNil)(seg) || (0, _utils.isNil)(index)) {
|
|
72
72
|
return null;
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -4,6 +4,13 @@ import type { DisplayObjectConfig } from '../dom';
|
|
|
4
4
|
export interface PolygonStyleProps extends BaseStyleProps {
|
|
5
5
|
points: [number, number][];
|
|
6
6
|
}
|
|
7
|
-
export
|
|
7
|
+
export interface ParsedPolygonStyleProps extends ParsedBaseStyleProps {
|
|
8
|
+
points: {
|
|
9
|
+
points: [number, number][];
|
|
10
|
+
segments: [number, number][];
|
|
11
|
+
totalLength: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare class Polygon extends DisplayObject<PolygonStyleProps, ParsedPolygonStyleProps> {
|
|
8
15
|
constructor({ style, ...rest }?: DisplayObjectConfig<PolygonStyleProps>);
|
|
9
16
|
}
|
|
@@ -5,12 +5,14 @@ import { Point } from '../shapes';
|
|
|
5
5
|
export interface PolylineStyleProps extends BaseStyleProps {
|
|
6
6
|
points: [number, number][];
|
|
7
7
|
}
|
|
8
|
-
export interface ParsedPolylineStyleProps {
|
|
9
|
-
points:
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
export interface ParsedPolylineStyleProps extends ParsedBaseStyleProps {
|
|
9
|
+
points: {
|
|
10
|
+
points: [number, number][];
|
|
11
|
+
segments: [number, number][];
|
|
12
|
+
totalLength: number;
|
|
13
|
+
};
|
|
12
14
|
}
|
|
13
|
-
export declare class Polyline extends DisplayObject<PolylineStyleProps,
|
|
15
|
+
export declare class Polyline extends DisplayObject<PolylineStyleProps, ParsedPolylineStyleProps> {
|
|
14
16
|
constructor({ style, ...rest }?: DisplayObjectConfig<PolylineStyleProps>);
|
|
15
17
|
getTotalLength(): number;
|
|
16
18
|
getPoint(ratio: number): Point;
|
package/lib/dom/Document.js
CHANGED
|
@@ -159,7 +159,7 @@ function (_super) {
|
|
|
159
159
|
}), clientX = _c.x, clientY = _c.y;
|
|
160
160
|
return [4
|
|
161
161
|
/*yield*/
|
|
162
|
-
, this.defaultView.getRenderingService().hooks.pick.
|
|
162
|
+
, this.defaultView.getRenderingService().hooks.pick.callPromise({
|
|
163
163
|
topmost: true,
|
|
164
164
|
position: {
|
|
165
165
|
x: x,
|
|
@@ -213,7 +213,7 @@ function (_super) {
|
|
|
213
213
|
}), clientX = _c.x, clientY = _c.y;
|
|
214
214
|
return [4
|
|
215
215
|
/*yield*/
|
|
216
|
-
, this.defaultView.getRenderingService().hooks.pick.
|
|
216
|
+
, this.defaultView.getRenderingService().hooks.pick.callPromise({
|
|
217
217
|
topmost: false,
|
|
218
218
|
position: {
|
|
219
219
|
x: x,
|
package/lib/dom/Element.js
CHANGED
|
@@ -9,8 +9,6 @@ var _tslib = require("tslib");
|
|
|
9
9
|
|
|
10
10
|
var _manaSyringe = require("mana-syringe");
|
|
11
11
|
|
|
12
|
-
var _lodashEs = require("lodash-es");
|
|
13
|
-
|
|
14
12
|
var _SceneGraphService = require("../services/SceneGraphService");
|
|
15
13
|
|
|
16
14
|
var _components = require("../components");
|
|
@@ -533,7 +531,7 @@ function (_super) {
|
|
|
533
531
|
|
|
534
532
|
var value = this.attributes[attributeName]; // if the given attribute does not exist, the value returned will either be null or ""
|
|
535
533
|
|
|
536
|
-
return (0,
|
|
534
|
+
return (0, _utils.isNil)(value) ? null : value;
|
|
537
535
|
};
|
|
538
536
|
/**
|
|
539
537
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttribute
|
package/lib/dom/EventTarget.js
CHANGED
|
@@ -7,14 +7,14 @@ exports.EventTarget = exports.DELEGATION_SPLITTER = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _tslib = require("tslib");
|
|
9
9
|
|
|
10
|
-
var _lodashEs = require("lodash-es");
|
|
11
|
-
|
|
12
10
|
var _eventemitter = require("eventemitter3");
|
|
13
11
|
|
|
14
12
|
var _CustomEvent = require("./CustomEvent");
|
|
15
13
|
|
|
16
14
|
var _FederatedEvent = require("./FederatedEvent");
|
|
17
15
|
|
|
16
|
+
var _utils = require("../utils");
|
|
17
|
+
|
|
18
18
|
var DELEGATION_SPLITTER = ':';
|
|
19
19
|
/**
|
|
20
20
|
* Objects that can receive events and may have listeners for them.
|
|
@@ -50,9 +50,9 @@ function () {
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
EventTarget.prototype.addEventListener = function (type, listener, options) {
|
|
53
|
-
var capture = (0,
|
|
54
|
-
var once = (0,
|
|
55
|
-
var context = (0,
|
|
53
|
+
var capture = (0, _utils.isBoolean)(options) && options || (0, _utils.isObject)(options) && options.capture;
|
|
54
|
+
var once = (0, _utils.isObject)(options) && options.once;
|
|
55
|
+
var context = (0, _utils.isFunction)(listener) ? undefined : listener; // compatible with G 3.0
|
|
56
56
|
// support using delegate name in event type, eg. 'node:click'
|
|
57
57
|
|
|
58
58
|
var useDelegatedName = false;
|
|
@@ -69,7 +69,7 @@ function () {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
type = capture ? "".concat(type, "capture") : type;
|
|
72
|
-
listener = (0,
|
|
72
|
+
listener = (0, _utils.isFunction)(listener) ? listener : listener.handleEvent; // compatible with G 3.0
|
|
73
73
|
|
|
74
74
|
if (useDelegatedName) {
|
|
75
75
|
var originListener_1 = listener;
|
|
@@ -122,10 +122,10 @@ function () {
|
|
|
122
122
|
};
|
|
123
123
|
|
|
124
124
|
EventTarget.prototype.removeEventListener = function (type, listener, options) {
|
|
125
|
-
var capture = (0,
|
|
126
|
-
var context = (0,
|
|
125
|
+
var capture = (0, _utils.isBoolean)(options) && options || (0, _utils.isObject)(options) && options.capture;
|
|
126
|
+
var context = (0, _utils.isFunction)(listener) ? undefined : listener;
|
|
127
127
|
type = capture ? "".concat(type, "capture") : type;
|
|
128
|
-
listener = (0,
|
|
128
|
+
listener = (0, _utils.isFunction)(listener) ? listener : listener === null || listener === void 0 ? void 0 : listener.handleEvent;
|
|
129
129
|
this.emitter.off(type, listener, context);
|
|
130
130
|
return this;
|
|
131
131
|
};
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import type { FormattedTouch } from '../utils';
|
|
1
2
|
import { FederatedEvent } from './FederatedEvent';
|
|
2
3
|
/**
|
|
3
4
|
* @see https://w3c.github.io/touch-events/#touchevent-interface
|
|
4
5
|
*/
|
|
5
6
|
export declare class FederatedTouchEvent extends FederatedEvent<MouseEvent | PointerEvent | TouchEvent> implements TouchEvent {
|
|
7
|
+
pointerType: string;
|
|
6
8
|
altKey: boolean;
|
|
7
9
|
ctrlKey: boolean;
|
|
8
10
|
metaKey: boolean;
|
|
9
11
|
shiftKey: boolean;
|
|
10
|
-
changedTouches:
|
|
11
|
-
targetTouches:
|
|
12
|
-
touches:
|
|
12
|
+
changedTouches: FormattedTouch[];
|
|
13
|
+
targetTouches: FormattedTouch[];
|
|
14
|
+
touches: FormattedTouch[];
|
|
13
15
|
}
|
|
@@ -11,7 +11,6 @@ export interface CullingStrategyContribution {
|
|
|
11
11
|
* 2. other custom culling strategies, eg. frustum culling
|
|
12
12
|
*/
|
|
13
13
|
export declare class CullingPlugin implements RenderingPlugin {
|
|
14
|
-
static tag: string;
|
|
15
14
|
private strategyProvider;
|
|
16
15
|
apply(renderingService: RenderingService): void;
|
|
17
16
|
}
|
|
@@ -26,11 +26,9 @@ var CullingPlugin =
|
|
|
26
26
|
function () {
|
|
27
27
|
function CullingPlugin() {}
|
|
28
28
|
|
|
29
|
-
CullingPlugin_1 = CullingPlugin;
|
|
30
|
-
|
|
31
29
|
CullingPlugin.prototype.apply = function (renderingService) {
|
|
32
30
|
var strategies = this.strategyProvider.getContributions();
|
|
33
|
-
renderingService.hooks.cull.tap(
|
|
31
|
+
renderingService.hooks.cull.tap(function (object) {
|
|
34
32
|
if (object) {
|
|
35
33
|
var cullable = object.cullable;
|
|
36
34
|
|
|
@@ -52,15 +50,13 @@ function () {
|
|
|
52
50
|
|
|
53
51
|
return object;
|
|
54
52
|
});
|
|
55
|
-
renderingService.hooks.afterRender.tap(
|
|
53
|
+
renderingService.hooks.afterRender.tap(function (object) {
|
|
56
54
|
object.cullable.visibilityPlaneMask = -1;
|
|
57
55
|
});
|
|
58
56
|
};
|
|
59
57
|
|
|
60
|
-
var CullingPlugin_1;
|
|
61
|
-
CullingPlugin.tag = 'CullingPlugin';
|
|
62
58
|
(0, _tslib.__decorate)([(0, _manaSyringe.contrib)(CullingStrategyContribution), (0, _tslib.__metadata)("design:type", Object)], CullingPlugin.prototype, "strategyProvider", void 0);
|
|
63
|
-
CullingPlugin =
|
|
59
|
+
CullingPlugin = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)({
|
|
64
60
|
contrib: _RenderingService.RenderingPluginContribution
|
|
65
61
|
})], CullingPlugin);
|
|
66
62
|
return CullingPlugin;
|