@antv/g 5.0.12 → 5.0.13
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 +1 -1
- package/es/dom/FederatedPointerEvent.d.ts +6 -0
- package/es/dom/FederatedPointerEvent.js +8 -0
- package/es/services/SceneGraphService.d.ts +0 -2
- package/es/services/SceneGraphService.js +54 -66
- package/lib/dom/FederatedPointerEvent.d.ts +6 -0
- package/lib/dom/FederatedPointerEvent.js +8 -0
- package/lib/services/SceneGraphService.d.ts +0 -2
- package/lib/services/SceneGraphService.js +54 -66
- package/package.json +3 -3
|
@@ -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!');
|
|
@@ -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;
|
|
@@ -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
|
/**
|
|
@@ -56,72 +56,6 @@ var DefaultSceneGraphService =
|
|
|
56
56
|
function () {
|
|
57
57
|
function DefaultSceneGraphService() {
|
|
58
58
|
var _this = this;
|
|
59
|
-
/**
|
|
60
|
-
* compare two display objects by hierarchy-index and z-index
|
|
61
|
-
*
|
|
62
|
-
* use materialized path
|
|
63
|
-
* @see https://stackoverflow.com/questions/31470730/comparing-tree-nodes
|
|
64
|
-
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
this.sort = function (object1, object2) {
|
|
68
|
-
if (!object1.parentNode) {
|
|
69
|
-
return -1;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (!object2.parentNode) {
|
|
73
|
-
return 1;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
var hierarchyDiff = object1.transformable.graphDepth - object2.transformable.graphDepth;
|
|
77
|
-
var o1 = object1;
|
|
78
|
-
var o2 = object2;
|
|
79
|
-
|
|
80
|
-
if (hierarchyDiff < 0) {
|
|
81
|
-
o2 = object2.getAncestor(-hierarchyDiff);
|
|
82
|
-
|
|
83
|
-
if (o2 === o1) {
|
|
84
|
-
return -1;
|
|
85
|
-
}
|
|
86
|
-
} else if (hierarchyDiff > 0) {
|
|
87
|
-
o1 = object1.getAncestor(hierarchyDiff);
|
|
88
|
-
|
|
89
|
-
if (o2 === o1) {
|
|
90
|
-
return 1;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
while (o1 && o2 && o1.parentNode !== o2.parentNode) {
|
|
95
|
-
o1 = o1.parentNode;
|
|
96
|
-
o2 = o2.parentNode;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
var parent = o1.parentNode;
|
|
100
|
-
|
|
101
|
-
if (parent) {
|
|
102
|
-
var parentSortable = parent.sortable;
|
|
103
|
-
|
|
104
|
-
if (parentSortable) {
|
|
105
|
-
// no need to re-sort, use cached sorted children
|
|
106
|
-
if (!parentSortable.sorted) {
|
|
107
|
-
parentSortable.sorted = parent.childNodes.slice();
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (parentSortable.dirty) {
|
|
111
|
-
parentSortable.sorted = parent.childNodes.slice().sort(sortByZIndex); // parentSortable.sorted.forEach(
|
|
112
|
-
// (child, i) => ((child as Element).sortable.lastSortedIndex = i),
|
|
113
|
-
// );
|
|
114
|
-
|
|
115
|
-
parentSortable.dirty = false;
|
|
116
|
-
} // return (o1 as Element).sortable.lastSortedIndex - (o2 as Element).sortable.lastSortedIndex;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return parentSortable.sorted.indexOf(o1) - parentSortable.sorted.indexOf(o2);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return -1;
|
|
124
|
-
};
|
|
125
59
|
/**
|
|
126
60
|
* rotate in world space
|
|
127
61
|
*/
|
|
@@ -437,6 +371,60 @@ function () {
|
|
|
437
371
|
child.parentNode = null;
|
|
438
372
|
}
|
|
439
373
|
};
|
|
374
|
+
/**
|
|
375
|
+
* compare two display objects by hierarchy-index and z-index
|
|
376
|
+
*
|
|
377
|
+
* use materialized path
|
|
378
|
+
* @see https://stackoverflow.com/questions/31470730/comparing-tree-nodes
|
|
379
|
+
*/
|
|
380
|
+
// sort = (object1: INode, object2: INode): number => {
|
|
381
|
+
// if (!object1.parentNode) {
|
|
382
|
+
// return -1;
|
|
383
|
+
// }
|
|
384
|
+
// if (!object2.parentNode) {
|
|
385
|
+
// return 1;
|
|
386
|
+
// }
|
|
387
|
+
// const hierarchyDiff =
|
|
388
|
+
// (object1 as Element).transformable.graphDepth - (object2 as Element).transformable.graphDepth;
|
|
389
|
+
// let o1 = object1;
|
|
390
|
+
// let o2 = object2;
|
|
391
|
+
// if (hierarchyDiff < 0) {
|
|
392
|
+
// o2 = object2.getAncestor(-hierarchyDiff)!;
|
|
393
|
+
// if (o2 === o1) {
|
|
394
|
+
// return -1;
|
|
395
|
+
// }
|
|
396
|
+
// } else if (hierarchyDiff > 0) {
|
|
397
|
+
// o1 = object1.getAncestor(hierarchyDiff)!;
|
|
398
|
+
// if (o2 === o1) {
|
|
399
|
+
// return 1;
|
|
400
|
+
// }
|
|
401
|
+
// }
|
|
402
|
+
// while (o1 && o2 && o1.parentNode !== o2.parentNode) {
|
|
403
|
+
// o1 = o1.parentNode!;
|
|
404
|
+
// o2 = o2.parentNode!;
|
|
405
|
+
// }
|
|
406
|
+
// const parent = o1.parentNode;
|
|
407
|
+
// if (parent) {
|
|
408
|
+
// const parentSortable = (parent as Element).sortable;
|
|
409
|
+
// if (parentSortable) {
|
|
410
|
+
// // no need to re-sort, use cached sorted children
|
|
411
|
+
// if (!parentSortable.sorted) {
|
|
412
|
+
// parentSortable.sorted = (parent.childNodes as IElement[]).slice();
|
|
413
|
+
// }
|
|
414
|
+
// if (parentSortable.dirty) {
|
|
415
|
+
// parentSortable.sorted = (parent.childNodes as IElement[]).slice().sort(sortByZIndex);
|
|
416
|
+
// // parentSortable.sorted.forEach(
|
|
417
|
+
// // (child, i) => ((child as Element).sortable.lastSortedIndex = i),
|
|
418
|
+
// // );
|
|
419
|
+
// parentSortable.dirty = false;
|
|
420
|
+
// }
|
|
421
|
+
// // return (o1 as Element).sortable.lastSortedIndex - (o2 as Element).sortable.lastSortedIndex;
|
|
422
|
+
// return parentSortable.sorted.indexOf(o1) - parentSortable.sorted.indexOf(o2);
|
|
423
|
+
// }
|
|
424
|
+
// }
|
|
425
|
+
// return -1;
|
|
426
|
+
// };
|
|
427
|
+
|
|
440
428
|
|
|
441
429
|
DefaultSceneGraphService.prototype.getOrigin = function (element) {
|
|
442
430
|
return element.transformable.origin;
|
|
@@ -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!');
|
|
@@ -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;
|
|
@@ -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
|
/**
|
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/g",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.13",
|
|
4
4
|
"description": "A core module including ECS and DI container.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/antvis/g#readme",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@antv/g-math": "^1.0.
|
|
40
|
+
"@antv/g-math": "^1.0.10",
|
|
41
41
|
"@antv/path-util": "^2.0.14",
|
|
42
42
|
"@antv/util": "^2.0.13",
|
|
43
43
|
"@types/offscreencanvas": "^2019.6.4",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"scripts": {
|
|
53
53
|
"umd": "webpack"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "e713211a92d77d0820e3252c3e8704aefda9c2e7"
|
|
56
56
|
}
|