@antv/g 1.0.0-alpha.20 → 1.0.0-alpha.24
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/es/Canvas.d.ts +40 -18
- package/es/Canvas.js +121 -65
- package/es/DisplayObjectPool.d.ts +2 -1
- package/es/DisplayObjectPool.js +4 -0
- package/{lib → es/camera}/Camera.d.ts +6 -3
- package/es/{Camera.js → camera/Camera.js} +22 -16
- package/es/{Landmark.d.ts → camera/Landmark.d.ts} +2 -2
- package/es/{Landmark.js → camera/Landmark.js} +1 -1
- package/es/camera/index.d.ts +2 -0
- package/es/camera/index.js +2 -0
- package/es/components/Cullable.js +1 -1
- package/es/components/Geometry.d.ts +8 -1
- package/es/components/Renderable.d.ts +9 -8
- package/es/components/Renderable.js +2 -6
- package/es/components/Sortable.d.ts +6 -2
- package/es/display-objects/Circle.d.ts +2 -3
- package/es/display-objects/Circle.js +2 -5
- package/es/{CustomElement.d.ts → display-objects/CustomElement.d.ts} +1 -1
- package/es/{CustomElement.js → display-objects/CustomElement.js} +22 -12
- package/{lib → es/display-objects}/DisplayObject.d.ts +136 -141
- package/es/{DisplayObject.js → display-objects/DisplayObject.js} +408 -292
- package/es/display-objects/Ellipse.d.ts +2 -3
- package/es/display-objects/Ellipse.js +2 -5
- package/es/display-objects/Group.d.ts +2 -1
- package/es/display-objects/Group.js +13 -5
- package/es/display-objects/HTML.d.ts +2 -2
- package/es/display-objects/HTML.js +4 -7
- package/es/display-objects/Image.d.ts +2 -2
- package/es/display-objects/Image.js +2 -6
- package/es/display-objects/Line.d.ts +2 -2
- package/es/display-objects/Line.js +8 -8
- package/es/display-objects/Path.d.ts +3 -2
- package/es/display-objects/Path.js +8 -8
- package/es/display-objects/Polygon.d.ts +2 -2
- package/es/display-objects/Polygon.js +2 -6
- package/es/display-objects/Polyline.d.ts +2 -2
- package/es/display-objects/Polyline.js +8 -8
- package/es/display-objects/Rect.d.ts +2 -2
- package/es/display-objects/Rect.js +2 -6
- package/es/display-objects/Text.d.ts +2 -3
- package/es/display-objects/Text.js +8 -7
- package/es/display-objects/index.d.ts +2 -0
- package/es/display-objects/index.js +2 -0
- package/es/{Animation.d.ts → dom/Animation.d.ts} +3 -3
- package/es/{Animation.js → dom/Animation.js} +2 -3
- package/{lib → es/dom}/AnimationEffectTiming.d.ts +2 -0
- package/es/{AnimationEffectTiming.js → dom/AnimationEffectTiming.js} +3 -2
- package/es/{AnimationEvent.d.ts → dom/AnimationEvent.d.ts} +3 -2
- package/es/{AnimationEvent.js → dom/AnimationEvent.js} +1 -1
- package/es/{Timeline.d.ts → dom/AnimationTimeline.d.ts} +1 -1
- package/es/{Timeline.js → dom/AnimationTimeline.js} +1 -1
- package/es/dom/CustomElementRegistry.d.ts +15 -0
- package/es/dom/CustomElementRegistry.js +40 -0
- package/{lib → es/dom}/CustomEvent.d.ts +1 -1
- package/es/{CustomEvent.js → dom/CustomEvent.js} +1 -1
- package/es/dom/Document.d.ts +36 -17
- package/es/dom/Document.js +98 -14
- package/es/dom/Element.d.ts +71 -92
- package/es/dom/Element.js +179 -195
- package/es/dom/EventTarget.d.ts +11 -6
- package/es/dom/EventTarget.js +12 -4
- package/es/dom/FederatedEvent.d.ts +15 -7
- package/es/dom/FederatedEvent.js +33 -0
- package/es/dom/FederatedMouseEvent.d.ts +1 -1
- package/es/{KeyframeEffect.d.ts → dom/KeyframeEffect.d.ts} +16 -5
- package/es/{KeyframeEffect.js → dom/KeyframeEffect.js} +50 -4
- package/es/{KeyframeList.d.ts → dom/KeyframeList.d.ts} +1 -1
- package/es/{KeyframeList.js → dom/KeyframeList.js} +0 -0
- package/es/dom/Node.d.ts +38 -23
- package/es/dom/Node.js +37 -33
- package/es/dom/index.d.ts +15 -2
- package/es/dom/index.js +16 -3
- package/es/dom/interfaces.d.ts +301 -0
- package/es/dom/interfaces.js +1 -0
- package/es/global-module.d.ts +0 -2
- package/es/global-module.js +31 -29
- package/es/index.d.ts +7 -14
- package/es/index.js +8 -15
- package/es/plugins/CullingPlugin.d.ts +2 -2
- package/es/plugins/CullingPlugin.js +13 -16
- package/es/plugins/DirtyCheckPlugin.d.ts +1 -1
- package/es/plugins/DirtyCheckPlugin.js +8 -7
- package/es/plugins/EventPlugin.js +52 -31
- package/es/plugins/FrustumCullingStrategy.d.ts +1 -1
- package/es/plugins/FrustumCullingStrategy.js +5 -4
- package/es/plugins/PrepareRendererPlugin.d.ts +0 -1
- package/es/plugins/PrepareRendererPlugin.js +42 -38
- package/es/property-handlers/aabb.d.ts +2 -3
- package/es/property-handlers/aabb.js +29 -21
- package/es/property-handlers/anchor.d.ts +3 -0
- package/es/property-handlers/anchor.js +21 -0
- package/es/property-handlers/clipPath.d.ts +1 -1
- package/es/property-handlers/clipPath.js +3 -4
- package/es/property-handlers/color.d.ts +1 -1
- package/es/property-handlers/dimension.d.ts +1 -1
- package/es/property-handlers/dimension.js +6 -9
- package/es/property-handlers/filter.d.ts +1 -1
- package/es/property-handlers/index.d.ts +5 -4
- package/es/property-handlers/index.js +1 -0
- package/es/property-handlers/localPosition.d.ts +1 -1
- package/es/property-handlers/localPosition.js +1 -6
- package/es/property-handlers/offsetDistance.d.ts +1 -1
- package/es/property-handlers/offsetPath.d.ts +1 -1
- package/es/property-handlers/origin.d.ts +1 -1
- package/es/property-handlers/origin.js +9 -2
- package/es/property-handlers/path.d.ts +2 -2
- package/es/property-handlers/path.js +8 -4
- package/es/property-handlers/points.d.ts +1 -1
- package/es/property-handlers/transform.d.ts +1 -1
- package/es/property-handlers/zIndex.d.ts +1 -1
- package/es/services/ContextService.d.ts +3 -2
- package/es/services/EventService.d.ts +18 -13
- package/es/services/EventService.js +604 -384
- package/es/services/RenderingContext.d.ts +1 -1
- package/es/services/RenderingService.d.ts +23 -29
- package/es/services/RenderingService.js +63 -54
- package/es/services/SceneGraphSelector.d.ts +7 -7
- package/es/services/SceneGraphSelector.js +10 -6
- package/es/services/SceneGraphService.d.ts +73 -78
- package/es/services/SceneGraphService.js +165 -78
- package/es/services/aabb/PathUpdater.d.ts +1 -1
- package/es/services/aabb/RectUpdater.d.ts +2 -2
- package/es/services/aabb/interfaces.d.ts +1 -1
- package/es/shapes/Point.d.ts +4 -0
- package/es/shapes/Polygon.d.ts +9 -0
- package/es/shapes/Polygon.js +62 -0
- package/es/shapes/index.d.ts +1 -0
- package/es/shapes/index.js +2 -1
- package/es/types.d.ts +18 -6
- package/es/utils/animation.d.ts +1 -2
- package/es/utils/animation.js +5 -10
- package/es/utils/canvas.d.ts +1 -1
- package/es/utils/custom-easing.d.ts +3 -2
- package/es/utils/custom-easing.js +12 -6
- package/es/utils/event.js +1 -1
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +2 -1
- package/es/utils/interpolation.d.ts +3 -4
- package/es/utils/interpolation.js +0 -16
- package/es/utils/path.d.ts +2 -2
- package/lib/Canvas.d.ts +40 -18
- package/lib/Canvas.js +131 -74
- package/lib/DisplayObjectPool.d.ts +2 -1
- package/lib/DisplayObjectPool.js +4 -0
- package/{es → lib/camera}/Camera.d.ts +6 -3
- package/lib/{Camera.js → camera/Camera.js} +25 -20
- package/lib/{Landmark.d.ts → camera/Landmark.d.ts} +2 -2
- package/lib/{Landmark.js → camera/Landmark.js} +2 -3
- package/lib/camera/index.d.ts +2 -0
- package/lib/camera/index.js +31 -0
- package/lib/components/Cullable.js +1 -1
- package/lib/components/Geometry.d.ts +8 -1
- package/lib/components/Renderable.d.ts +9 -8
- package/lib/components/Renderable.js +2 -6
- package/lib/components/Sortable.d.ts +6 -2
- package/lib/display-objects/Circle.d.ts +2 -3
- package/lib/display-objects/Circle.js +3 -6
- package/lib/{CustomElement.d.ts → display-objects/CustomElement.d.ts} +1 -1
- package/lib/{CustomElement.js → display-objects/CustomElement.js} +22 -12
- package/{es → lib/display-objects}/DisplayObject.d.ts +136 -141
- package/lib/{DisplayObject.js → display-objects/DisplayObject.js} +418 -299
- package/lib/display-objects/Ellipse.d.ts +2 -3
- package/lib/display-objects/Ellipse.js +3 -6
- package/lib/display-objects/Group.d.ts +2 -1
- package/lib/display-objects/Group.js +12 -4
- package/lib/display-objects/HTML.d.ts +2 -2
- package/lib/display-objects/HTML.js +4 -7
- package/lib/display-objects/Image.d.ts +2 -2
- package/lib/display-objects/Image.js +2 -6
- package/lib/display-objects/Line.d.ts +2 -2
- package/lib/display-objects/Line.js +8 -8
- package/lib/display-objects/Path.d.ts +3 -2
- package/lib/display-objects/Path.js +8 -8
- package/lib/display-objects/Polygon.d.ts +2 -2
- package/lib/display-objects/Polygon.js +2 -6
- package/lib/display-objects/Polyline.d.ts +2 -2
- package/lib/display-objects/Polyline.js +8 -8
- package/lib/display-objects/Rect.d.ts +2 -2
- package/lib/display-objects/Rect.js +2 -6
- package/lib/display-objects/Text.d.ts +2 -3
- package/lib/display-objects/Text.js +9 -8
- package/lib/display-objects/index.d.ts +2 -0
- package/lib/display-objects/index.js +26 -0
- package/lib/{Animation.d.ts → dom/Animation.d.ts} +3 -3
- package/lib/{Animation.js → dom/Animation.js} +2 -3
- package/{es → lib/dom}/AnimationEffectTiming.d.ts +2 -0
- package/lib/{AnimationEffectTiming.js → dom/AnimationEffectTiming.js} +3 -3
- package/lib/{AnimationEvent.d.ts → dom/AnimationEvent.d.ts} +3 -2
- package/lib/{AnimationEvent.js → dom/AnimationEvent.js} +1 -1
- package/lib/{Timeline.d.ts → dom/AnimationTimeline.d.ts} +1 -1
- package/lib/{Timeline.js → dom/AnimationTimeline.js} +1 -1
- package/lib/dom/CustomElementRegistry.d.ts +15 -0
- package/lib/dom/CustomElementRegistry.js +48 -0
- package/{es → lib/dom}/CustomEvent.d.ts +1 -1
- package/lib/{CustomEvent.js → dom/CustomEvent.js} +1 -1
- package/lib/dom/Document.d.ts +36 -17
- package/lib/dom/Document.js +99 -15
- package/lib/dom/Element.d.ts +71 -92
- package/lib/dom/Element.js +180 -198
- package/lib/dom/EventTarget.d.ts +11 -6
- package/lib/dom/EventTarget.js +20 -10
- package/lib/dom/FederatedEvent.d.ts +15 -7
- package/lib/dom/FederatedEvent.js +33 -0
- package/lib/dom/FederatedMouseEvent.d.ts +1 -1
- package/lib/{KeyframeEffect.d.ts → dom/KeyframeEffect.d.ts} +16 -5
- package/lib/{KeyframeEffect.js → dom/KeyframeEffect.js} +50 -4
- package/lib/{KeyframeList.d.ts → dom/KeyframeList.d.ts} +1 -1
- package/lib/{KeyframeList.js → dom/KeyframeList.js} +0 -0
- package/lib/dom/Node.d.ts +38 -23
- package/lib/dom/Node.js +37 -33
- package/lib/dom/index.d.ts +15 -2
- package/lib/dom/index.js +177 -8
- package/lib/dom/interfaces.d.ts +301 -0
- package/lib/dom/interfaces.js +5 -0
- package/lib/global-module.d.ts +0 -2
- package/lib/global-module.js +30 -30
- package/lib/index.d.ts +7 -14
- package/lib/index.js +44 -135
- package/lib/plugins/CullingPlugin.d.ts +2 -2
- package/lib/plugins/CullingPlugin.js +14 -16
- package/lib/plugins/DirtyCheckPlugin.d.ts +1 -1
- package/lib/plugins/DirtyCheckPlugin.js +9 -7
- package/lib/plugins/EventPlugin.js +52 -30
- package/lib/plugins/FrustumCullingStrategy.d.ts +1 -1
- package/lib/plugins/FrustumCullingStrategy.js +5 -4
- package/lib/plugins/PrepareRendererPlugin.d.ts +0 -1
- package/lib/plugins/PrepareRendererPlugin.js +41 -37
- package/lib/property-handlers/aabb.d.ts +2 -3
- package/lib/property-handlers/aabb.js +28 -22
- package/lib/property-handlers/anchor.d.ts +3 -0
- package/lib/property-handlers/anchor.js +34 -0
- package/lib/property-handlers/clipPath.d.ts +1 -1
- package/lib/property-handlers/clipPath.js +3 -4
- package/lib/property-handlers/color.d.ts +1 -1
- package/lib/property-handlers/dimension.d.ts +1 -1
- package/lib/property-handlers/dimension.js +6 -9
- package/lib/property-handlers/filter.d.ts +1 -1
- package/lib/property-handlers/index.d.ts +5 -4
- package/lib/property-handlers/index.js +14 -0
- package/lib/property-handlers/localPosition.d.ts +1 -1
- package/lib/property-handlers/localPosition.js +1 -7
- package/lib/property-handlers/offsetDistance.d.ts +1 -1
- package/lib/property-handlers/offsetPath.d.ts +1 -1
- package/lib/property-handlers/origin.d.ts +1 -1
- package/lib/property-handlers/origin.js +10 -2
- package/lib/property-handlers/path.d.ts +2 -2
- package/lib/property-handlers/path.js +8 -4
- package/lib/property-handlers/points.d.ts +1 -1
- package/lib/property-handlers/transform.d.ts +1 -1
- package/lib/property-handlers/zIndex.d.ts +1 -1
- package/lib/services/ContextService.d.ts +3 -2
- package/lib/services/EventService.d.ts +18 -13
- package/lib/services/EventService.js +616 -385
- package/lib/services/RenderingContext.d.ts +1 -1
- package/lib/services/RenderingService.d.ts +23 -29
- package/lib/services/RenderingService.js +66 -56
- package/lib/services/SceneGraphSelector.d.ts +7 -7
- package/lib/services/SceneGraphSelector.js +10 -6
- package/lib/services/SceneGraphService.d.ts +73 -78
- package/lib/services/SceneGraphService.js +166 -79
- package/lib/services/aabb/PathUpdater.d.ts +1 -1
- package/lib/services/aabb/RectUpdater.d.ts +2 -2
- package/lib/services/aabb/interfaces.d.ts +1 -1
- package/lib/shapes/Point.d.ts +4 -0
- package/lib/shapes/Polygon.d.ts +9 -0
- package/lib/shapes/Polygon.js +69 -0
- package/lib/shapes/index.d.ts +1 -0
- package/lib/shapes/index.js +13 -0
- package/lib/types.d.ts +18 -6
- package/lib/utils/animation.d.ts +1 -2
- package/lib/utils/animation.js +8 -16
- package/lib/utils/canvas.d.ts +1 -1
- package/lib/utils/custom-easing.d.ts +3 -2
- package/lib/utils/custom-easing.js +16 -8
- package/lib/utils/event.js +1 -1
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +13 -0
- package/lib/utils/interpolation.d.ts +3 -4
- package/lib/utils/interpolation.js +0 -17
- package/lib/utils/path.d.ts +2 -2
- package/package.json +6 -6
- package/es/Batch.d.ts +0 -25
- package/es/Batch.js +0 -82
- package/es/shapes-type.d.ts +0 -175
- package/es/shapes-type.js +0 -18
- package/es/utils/matrix-decompose.d.ts +0 -3
- package/es/utils/matrix-decompose.js +0 -404
- package/lib/Batch.d.ts +0 -25
- package/lib/Batch.js +0 -91
- package/lib/shapes-type.d.ts +0 -175
- package/lib/shapes-type.js +0 -41
- package/lib/utils/matrix-decompose.d.ts +0 -3
- package/lib/utils/matrix-decompose.js +0 -414
package/lib/dom/Document.d.ts
CHANGED
|
@@ -1,39 +1,58 @@
|
|
|
1
|
-
import { Canvas } from '../Canvas';
|
|
2
1
|
import { Node } from './Node';
|
|
3
|
-
import { AnimationTimeline } from '
|
|
4
|
-
import { Group } from '../display-objects';
|
|
5
|
-
import {
|
|
2
|
+
import { AnimationTimeline } from './AnimationTimeline';
|
|
3
|
+
import { Group, DisplayObject } from '../display-objects';
|
|
4
|
+
import type { IDocument, IElement, INode, ICanvas, DisplayObjectConfig } from './interfaces';
|
|
5
|
+
import { BaseStyleProps } from '../types';
|
|
6
6
|
/**
|
|
7
7
|
* the entry of DOM tree
|
|
8
8
|
* Document -> Node -> EventTarget
|
|
9
9
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document
|
|
10
10
|
*/
|
|
11
|
-
export declare class Document extends Node {
|
|
11
|
+
export declare class Document extends Node implements IDocument {
|
|
12
12
|
constructor();
|
|
13
|
+
get children(): IElement[];
|
|
14
|
+
get childElementCount(): number;
|
|
15
|
+
get firstElementChild(): IElement | null;
|
|
16
|
+
get lastElementChild(): IElement | null;
|
|
13
17
|
/**
|
|
14
18
|
* only document has defaultView, points to canvas,
|
|
15
19
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/defaultView
|
|
16
20
|
*/
|
|
17
|
-
defaultView:
|
|
21
|
+
defaultView: ICanvas | null;
|
|
18
22
|
/**
|
|
19
23
|
* the root element of document, eg. <html>
|
|
20
24
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/documentElement
|
|
21
25
|
*/
|
|
22
|
-
documentElement: Group;
|
|
26
|
+
readonly documentElement: Group;
|
|
23
27
|
/**
|
|
24
28
|
* document.timeline in WAAPI
|
|
25
29
|
*/
|
|
26
|
-
timeline: AnimationTimeline;
|
|
30
|
+
readonly timeline: AnimationTimeline;
|
|
31
|
+
readonly ownerDocument: any;
|
|
32
|
+
/**
|
|
33
|
+
* @example const circle = document.createElement('circle', { style: { r: 10 } });
|
|
34
|
+
*/
|
|
35
|
+
createElement<T extends DisplayObject<StyleProps>, StyleProps extends BaseStyleProps>(tagName: string, options: DisplayObjectConfig<StyleProps>): T;
|
|
36
|
+
cloneNode(deep?: boolean): INode;
|
|
37
|
+
destroy(): void;
|
|
27
38
|
/**
|
|
28
39
|
* eg. Uncaught DOMException: Failed to execute 'appendChild' on 'Node': Only one element on document allowed.
|
|
29
40
|
*/
|
|
30
|
-
appendChild(
|
|
31
|
-
insertBefore(
|
|
32
|
-
removeChild(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
appendChild<T extends INode>(newChild: T, index?: number): T;
|
|
42
|
+
insertBefore<T extends INode>(newChild: T, refChild: INode | null): T;
|
|
43
|
+
removeChild<T extends INode>(oldChild: T, destroy?: boolean): T;
|
|
44
|
+
replaceChild<T extends INode>(newChild: INode, oldChild: T, destroy?: boolean): T;
|
|
45
|
+
append(...nodes: INode[]): void;
|
|
46
|
+
prepend(...nodes: INode[]): void;
|
|
47
|
+
/**
|
|
48
|
+
* Execute query on documentElement.
|
|
49
|
+
*/
|
|
50
|
+
getElementById<E extends IElement = IElement>(id: string): E | null;
|
|
51
|
+
getElementsByName<E extends IElement = IElement>(name: string): E[];
|
|
52
|
+
getElementsByTagName<E extends IElement = IElement>(tagName: string): E[];
|
|
53
|
+
getElementsByClassName<E extends IElement = IElement>(className: string): E[];
|
|
54
|
+
querySelector<E extends IElement = IElement>(selectors: string): E | null;
|
|
55
|
+
querySelectorAll<E extends IElement = IElement>(selectors: string): E[];
|
|
56
|
+
find<E extends IElement = IElement>(filter: (node: E) => boolean): E | null;
|
|
57
|
+
findAll<E extends IElement = IElement>(filter: (node: E) => boolean): E[];
|
|
39
58
|
}
|
package/lib/dom/Document.js
CHANGED
|
@@ -9,7 +9,7 @@ var _tslib = require("tslib");
|
|
|
9
9
|
|
|
10
10
|
var _Node = require("./Node");
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _AnimationTimeline = require("./AnimationTimeline");
|
|
13
13
|
|
|
14
14
|
var _displayObjects = require("../display-objects");
|
|
15
15
|
|
|
@@ -30,36 +30,112 @@ var Document = function (_super) {
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
_this.defaultView = null;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*/
|
|
33
|
+
_this.ownerDocument = null;
|
|
34
|
+
_this.nodeName = 'document'; // create timeline
|
|
36
35
|
|
|
37
|
-
_this.timeline = new
|
|
36
|
+
_this.timeline = new _AnimationTimeline.AnimationTimeline(); // like <html> in DOM tree
|
|
38
37
|
|
|
39
38
|
_this.documentElement = new _displayObjects.Group({
|
|
40
39
|
id: 'g-root'
|
|
41
40
|
});
|
|
42
|
-
_this.
|
|
41
|
+
_this.documentElement.ownerDocument = _this;
|
|
43
42
|
_this.documentElement.parentNode = _this;
|
|
44
43
|
_this.childNodes = [_this.documentElement];
|
|
45
44
|
return _this;
|
|
46
45
|
}
|
|
46
|
+
|
|
47
|
+
Object.defineProperty(Document.prototype, "children", {
|
|
48
|
+
get: function get() {
|
|
49
|
+
return this.childNodes;
|
|
50
|
+
},
|
|
51
|
+
enumerable: false,
|
|
52
|
+
configurable: true
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(Document.prototype, "childElementCount", {
|
|
55
|
+
get: function get() {
|
|
56
|
+
return this.childNodes.length;
|
|
57
|
+
},
|
|
58
|
+
enumerable: false,
|
|
59
|
+
configurable: true
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(Document.prototype, "firstElementChild", {
|
|
62
|
+
get: function get() {
|
|
63
|
+
return this.firstChild;
|
|
64
|
+
},
|
|
65
|
+
enumerable: false,
|
|
66
|
+
configurable: true
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(Document.prototype, "lastElementChild", {
|
|
69
|
+
get: function get() {
|
|
70
|
+
return this.lastChild;
|
|
71
|
+
},
|
|
72
|
+
enumerable: false,
|
|
73
|
+
configurable: true
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* @example const circle = document.createElement('circle', { style: { r: 10 } });
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
Document.prototype.createElement = function (tagName, options) {
|
|
80
|
+
var clazz = this.defaultView.customElements.get(tagName);
|
|
81
|
+
return new clazz(options);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
Document.prototype.cloneNode = function (deep) {
|
|
85
|
+
throw new Error('Method not implemented.');
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
Document.prototype.destroy = function () {
|
|
89
|
+
try {
|
|
90
|
+
this.documentElement.destroy();
|
|
91
|
+
} catch (e) {}
|
|
92
|
+
|
|
93
|
+
this.timeline.destroy();
|
|
94
|
+
};
|
|
47
95
|
/**
|
|
48
96
|
* eg. Uncaught DOMException: Failed to execute 'appendChild' on 'Node': Only one element on document allowed.
|
|
49
97
|
*/
|
|
50
98
|
|
|
51
99
|
|
|
52
|
-
Document.prototype.appendChild = function (
|
|
100
|
+
Document.prototype.appendChild = function (newChild, index) {
|
|
101
|
+
throw new Error('Use document.documentElement instead.');
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
Document.prototype.insertBefore = function (newChild, refChild) {
|
|
105
|
+
throw new Error('Use document.documentElement instead.');
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
Document.prototype.removeChild = function (oldChild, destroy) {
|
|
109
|
+
throw new Error('Use document.documentElement instead.');
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
Document.prototype.replaceChild = function (newChild, oldChild, destroy) {
|
|
53
113
|
throw new Error('Use document.documentElement instead.');
|
|
54
114
|
};
|
|
55
115
|
|
|
56
|
-
Document.prototype.
|
|
116
|
+
Document.prototype.append = function () {
|
|
117
|
+
var nodes = [];
|
|
118
|
+
|
|
119
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
120
|
+
nodes[_i] = arguments[_i];
|
|
121
|
+
}
|
|
122
|
+
|
|
57
123
|
throw new Error('Use document.documentElement instead.');
|
|
58
124
|
};
|
|
59
125
|
|
|
60
|
-
Document.prototype.
|
|
126
|
+
Document.prototype.prepend = function () {
|
|
127
|
+
var nodes = [];
|
|
128
|
+
|
|
129
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
130
|
+
nodes[_i] = arguments[_i];
|
|
131
|
+
}
|
|
132
|
+
|
|
61
133
|
throw new Error('Use document.documentElement instead.');
|
|
62
134
|
};
|
|
135
|
+
/**
|
|
136
|
+
* Execute query on documentElement.
|
|
137
|
+
*/
|
|
138
|
+
|
|
63
139
|
|
|
64
140
|
Document.prototype.getElementById = function (id) {
|
|
65
141
|
return this.documentElement.getElementById(id);
|
|
@@ -69,20 +145,28 @@ var Document = function (_super) {
|
|
|
69
145
|
return this.documentElement.getElementsByName(name);
|
|
70
146
|
};
|
|
71
147
|
|
|
148
|
+
Document.prototype.getElementsByTagName = function (tagName) {
|
|
149
|
+
return this.documentElement.getElementsByTagName(tagName);
|
|
150
|
+
};
|
|
151
|
+
|
|
72
152
|
Document.prototype.getElementsByClassName = function (className) {
|
|
73
153
|
return this.documentElement.getElementsByClassName(className);
|
|
74
154
|
};
|
|
75
155
|
|
|
76
|
-
Document.prototype.
|
|
77
|
-
return this.documentElement.
|
|
156
|
+
Document.prototype.querySelector = function (selectors) {
|
|
157
|
+
return this.documentElement.querySelector(selectors);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
Document.prototype.querySelectorAll = function (selectors) {
|
|
161
|
+
return this.documentElement.querySelectorAll(selectors);
|
|
78
162
|
};
|
|
79
163
|
|
|
80
|
-
Document.prototype.
|
|
81
|
-
return this.documentElement.
|
|
164
|
+
Document.prototype.find = function (filter) {
|
|
165
|
+
return this.documentElement.find(filter);
|
|
82
166
|
};
|
|
83
167
|
|
|
84
|
-
Document.prototype.
|
|
85
|
-
return this.documentElement.
|
|
168
|
+
Document.prototype.findAll = function (filter) {
|
|
169
|
+
return this.documentElement.findAll(filter);
|
|
86
170
|
};
|
|
87
171
|
|
|
88
172
|
return Document;
|
package/lib/dom/Element.d.ts
CHANGED
|
@@ -1,42 +1,33 @@
|
|
|
1
1
|
import { SceneGraphService } from '../services';
|
|
2
|
-
import
|
|
2
|
+
import { BaseStyleProps, ParsedBaseStyleProps } from '../types';
|
|
3
3
|
import { Node } from './Node';
|
|
4
|
-
import type { Animation } from '../Animation';
|
|
5
4
|
import { AABB, Rectangle } from '../shapes';
|
|
5
|
+
import type { DisplayObjectConfig, IEventTarget, IChildNode, IElement, INode } from './interfaces';
|
|
6
6
|
/**
|
|
7
|
-
* events for
|
|
7
|
+
* built-in events for element
|
|
8
8
|
*/
|
|
9
|
-
export declare enum
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
AttributeChanged = "attributeChanged",
|
|
9
|
+
export declare enum ElementEvent {
|
|
10
|
+
DESTROY = "destroy",
|
|
11
|
+
ATTRIBUTE_CHANGED = "attribute-changed",
|
|
13
12
|
/**
|
|
14
13
|
* it has been inserted
|
|
15
14
|
*/
|
|
16
|
-
|
|
15
|
+
INSERTED = "inserted",
|
|
17
16
|
/**
|
|
18
17
|
* it has had a child inserted
|
|
19
18
|
*/
|
|
20
|
-
|
|
19
|
+
CHILD_INSERTED = "child-inserted",
|
|
21
20
|
/**
|
|
22
21
|
* it has been removed
|
|
23
22
|
*/
|
|
24
|
-
|
|
23
|
+
REMOVED = "removed",
|
|
25
24
|
/**
|
|
26
25
|
* it has had a child removed
|
|
27
26
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
* element's identifier, must be unique in a document.
|
|
33
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/id
|
|
34
|
-
*/
|
|
35
|
-
id?: string;
|
|
36
|
-
name?: string;
|
|
37
|
-
className?: string;
|
|
38
|
-
attributes?: StyleProps;
|
|
39
|
-
type?: string;
|
|
27
|
+
CHILD_REMOVED = "child-removed",
|
|
28
|
+
MOUNTED = "mounted",
|
|
29
|
+
UNMOUNTED = "unmounted",
|
|
30
|
+
BOUNDS_CHANGED = "bounds-changed"
|
|
40
31
|
}
|
|
41
32
|
/**
|
|
42
33
|
* Has following capabilities:
|
|
@@ -44,13 +35,10 @@ export interface ElementConfig<StyleProps> {
|
|
|
44
35
|
* * Query eg. querySelector getElementById...
|
|
45
36
|
* * Animation
|
|
46
37
|
*/
|
|
47
|
-
export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyleProps extends ParsedBaseStyleProps = any> extends Node {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
activeAnimations: Animation[];
|
|
52
|
-
protected sceneGraphService: SceneGraphService;
|
|
53
|
-
constructor();
|
|
38
|
+
export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyleProps extends ParsedBaseStyleProps = any> extends Node implements IElement<StyleProps, ParsedStyleProps> {
|
|
39
|
+
static isElement(target: IEventTarget | INode | IElement): target is IElement;
|
|
40
|
+
sceneGraphService: SceneGraphService;
|
|
41
|
+
constructor(config: DisplayObjectConfig<StyleProps>);
|
|
54
42
|
/**
|
|
55
43
|
* used with `getElementById()`
|
|
56
44
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/id
|
|
@@ -71,104 +59,72 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
|
|
|
71
59
|
*/
|
|
72
60
|
get classList(): string[];
|
|
73
61
|
interactive: boolean;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
get children(): this[];
|
|
62
|
+
scrollLeft: number;
|
|
63
|
+
scrollTop: number;
|
|
64
|
+
get tagName(): string;
|
|
65
|
+
get children(): IElement[];
|
|
79
66
|
get childElementCount(): number;
|
|
80
|
-
get firstElementChild():
|
|
81
|
-
get lastElementChild():
|
|
67
|
+
get firstElementChild(): IElement | null;
|
|
68
|
+
get lastElementChild(): IElement | null;
|
|
69
|
+
get parentElement(): IElement | null;
|
|
70
|
+
get nextSibling(): IElement | null;
|
|
71
|
+
get previousSibling(): IElement | null;
|
|
72
|
+
cloneNode(deep?: boolean): this;
|
|
73
|
+
appendChild<T extends INode>(child: T, index?: number): T;
|
|
74
|
+
insertBefore<T extends INode>(newChild: T, refChild: IElement | null): T;
|
|
75
|
+
replaceChild<T extends INode & IChildNode>(newChild: INode, oldChild: T, destroy?: boolean): T;
|
|
76
|
+
removeChild<T extends INode>(child: T, destroy?: boolean): T;
|
|
77
|
+
removeChildren(destroy?: boolean): void;
|
|
82
78
|
/**
|
|
83
79
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
|
|
84
80
|
*/
|
|
85
81
|
matches(selector: string): boolean;
|
|
86
|
-
getElementById(id: string):
|
|
87
|
-
getElementsByName(name: string):
|
|
88
|
-
getElementsByClassName(className: string):
|
|
89
|
-
getElementsByTagName(tagName: string):
|
|
90
|
-
querySelector(
|
|
91
|
-
querySelectorAll(
|
|
92
|
-
/**
|
|
93
|
-
* traverse in descendants
|
|
94
|
-
*/
|
|
95
|
-
forEach(callback: (o: this) => void | boolean): void;
|
|
82
|
+
getElementById<E extends IElement = IElement>(id: string): E | null;
|
|
83
|
+
getElementsByName<E extends IElement = IElement>(name: string): E[];
|
|
84
|
+
getElementsByClassName<E extends IElement = IElement>(className: string): E[];
|
|
85
|
+
getElementsByTagName<E extends IElement = IElement>(tagName: string): E[];
|
|
86
|
+
querySelector<E extends IElement = IElement>(selectors: string): E | null;
|
|
87
|
+
querySelectorAll<E extends IElement = IElement>(selectors: string): E[];
|
|
96
88
|
/**
|
|
97
89
|
* search in scene group, but should not include itself
|
|
98
90
|
*/
|
|
99
|
-
find(filter: (node:
|
|
100
|
-
findAll(filter: (node:
|
|
101
|
-
/**
|
|
102
|
-
* compatible with `style`
|
|
103
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style
|
|
104
|
-
*/
|
|
105
|
-
style: StyleProps;
|
|
106
|
-
parsedStyle: ParsedStyleProps;
|
|
107
|
-
/**
|
|
108
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes
|
|
109
|
-
*/
|
|
110
|
-
attributes: StyleProps;
|
|
111
|
-
/**
|
|
112
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute
|
|
113
|
-
*/
|
|
114
|
-
getAttribute(attributeName: keyof StyleProps): StyleProps[keyof StyleProps];
|
|
115
|
-
/**
|
|
116
|
-
* should use removeAttribute() instead of setting the attribute value to null either directly or using setAttribute(). Many attributes will not behave as expected if you set them to null.
|
|
117
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute
|
|
118
|
-
*/
|
|
119
|
-
removeAttribute(attributeName: keyof StyleProps): void;
|
|
120
|
-
/**
|
|
121
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute
|
|
122
|
-
*/
|
|
123
|
-
setAttribute<Key extends keyof StyleProps>(attributeName: Key, value: StyleProps[Key], force?: boolean): void;
|
|
91
|
+
find<E extends IElement = IElement>(filter: (node: E) => boolean): E | null;
|
|
92
|
+
findAll<E extends IElement = IElement>(filter: (node: E) => boolean): E[];
|
|
124
93
|
/**
|
|
125
94
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/after
|
|
126
95
|
*/
|
|
127
|
-
after(...nodes:
|
|
96
|
+
after(...nodes: IElement[]): void;
|
|
128
97
|
/**
|
|
129
98
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/before
|
|
130
99
|
*/
|
|
131
|
-
before(...nodes:
|
|
100
|
+
before(...nodes: IElement[]): void;
|
|
132
101
|
/**
|
|
133
102
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/replaceWith
|
|
134
103
|
*/
|
|
135
|
-
replaceWith(...nodes:
|
|
104
|
+
replaceWith(...nodes: IElement[]): void;
|
|
136
105
|
/**
|
|
137
106
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/append
|
|
138
107
|
*/
|
|
139
|
-
append(...nodes:
|
|
108
|
+
append(...nodes: IElement[]): void;
|
|
140
109
|
/**
|
|
141
110
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/prepend
|
|
142
111
|
*/
|
|
143
|
-
prepend(...nodes:
|
|
112
|
+
prepend(...nodes: IElement[]): void;
|
|
144
113
|
/**
|
|
145
114
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/replaceChildren
|
|
146
115
|
*/
|
|
147
|
-
replaceChildren(...nodes:
|
|
116
|
+
replaceChildren(...nodes: IElement[]): void;
|
|
148
117
|
/**
|
|
149
118
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/remove
|
|
150
119
|
*/
|
|
151
|
-
remove(destroy?: boolean):
|
|
152
|
-
/**
|
|
153
|
-
* @override
|
|
154
|
-
*/
|
|
155
|
-
protected changeAttribute<Key extends keyof StyleProps>(name: Key, value: StyleProps[Key]): void;
|
|
120
|
+
remove(destroy?: boolean): this;
|
|
156
121
|
/**
|
|
157
122
|
* is destroyed or not
|
|
158
123
|
*/
|
|
159
124
|
destroyed: boolean;
|
|
160
125
|
destroy(): void;
|
|
161
|
-
/**
|
|
162
|
-
* returns an array of all Animation objects affecting this element
|
|
163
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAnimations
|
|
164
|
-
*/
|
|
165
|
-
getAnimations(): Animation[];
|
|
166
|
-
/**
|
|
167
|
-
* create an animation with WAAPI
|
|
168
|
-
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/animate
|
|
169
|
-
*/
|
|
170
|
-
animate(keyframes: Keyframe[] | PropertyIndexedKeyframes | null, options?: number | KeyframeAnimationOptions | undefined): Animation | null;
|
|
171
126
|
getGeometryBounds(): AABB | null;
|
|
127
|
+
getRenderBounds(): AABB | null;
|
|
172
128
|
/**
|
|
173
129
|
* get bounds in world space, account for children
|
|
174
130
|
*/
|
|
@@ -187,4 +143,27 @@ export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyl
|
|
|
187
143
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/getClientRects
|
|
188
144
|
*/
|
|
189
145
|
getClientRects(): Rectangle[];
|
|
146
|
+
/**
|
|
147
|
+
* compatible with `style`
|
|
148
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style
|
|
149
|
+
*/
|
|
150
|
+
style: StyleProps;
|
|
151
|
+
parsedStyle: ParsedStyleProps;
|
|
152
|
+
/**
|
|
153
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes
|
|
154
|
+
*/
|
|
155
|
+
attributes: StyleProps;
|
|
156
|
+
/**
|
|
157
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute
|
|
158
|
+
*/
|
|
159
|
+
getAttribute(attributeName: keyof StyleProps): StyleProps[keyof StyleProps];
|
|
160
|
+
/**
|
|
161
|
+
* should use removeAttribute() instead of setting the attribute value to null either directly or using setAttribute(). Many attributes will not behave as expected if you set them to null.
|
|
162
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute
|
|
163
|
+
*/
|
|
164
|
+
removeAttribute(attributeName: keyof StyleProps): void;
|
|
165
|
+
/**
|
|
166
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute
|
|
167
|
+
*/
|
|
168
|
+
setAttribute<Key extends keyof StyleProps>(attributeName: Key, value: StyleProps[Key], force?: boolean): void;
|
|
190
169
|
}
|