@visactor/vgrammar-core 0.14.0-alpha.1 → 0.14.0-alpha.3
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/cjs/component/axis.d.ts +0 -2
- package/cjs/component/axis.js +1 -15
- package/cjs/component/axis.js.map +1 -1
- package/cjs/component/grid.d.ts +0 -2
- package/cjs/component/grid.js +1 -15
- package/cjs/component/grid.js.map +1 -1
- package/cjs/component/index.d.ts +2 -2
- package/cjs/component/index.js +1 -21
- package/cjs/component/index.js.map +1 -1
- package/cjs/core/factory.d.ts +1 -8
- package/cjs/core/factory.js +1 -8
- package/cjs/core/factory.js.map +1 -1
- package/cjs/glyph/boxplot.js +5 -5
- package/cjs/glyph/boxplot.js.map +1 -1
- package/cjs/glyph/link-path.js +2 -2
- package/cjs/glyph/link-path.js.map +1 -1
- package/cjs/glyph/ripple.js +2 -3
- package/cjs/glyph/ripple.js.map +1 -1
- package/cjs/glyph/tree-path.js +2 -2
- package/cjs/glyph/tree-path.js.map +1 -1
- package/cjs/glyph/violin.js +4 -4
- package/cjs/glyph/violin.js.map +1 -1
- package/cjs/glyph/wave.js +2 -3
- package/cjs/glyph/wave.js.map +1 -1
- package/cjs/graph/animation/animation/fade.js +4 -4
- package/cjs/graph/animation/animation/fade.js.map +1 -1
- package/cjs/graph/animation/animation/grow-cartesian.js +14 -14
- package/cjs/graph/animation/animation/grow-cartesian.js.map +1 -1
- package/cjs/graph/animation/animation/grow-interval.js +9 -9
- package/cjs/graph/animation/animation/grow-interval.js.map +1 -1
- package/cjs/graph/animation/animation/grow-points.js +9 -9
- package/cjs/graph/animation/animation/grow-points.js.map +1 -1
- package/cjs/graph/animation/animation/grow-polar.js +24 -24
- package/cjs/graph/animation/animation/grow-polar.js.map +1 -1
- package/cjs/graph/animation/animation/move.js +6 -6
- package/cjs/graph/animation/animation/move.js.map +1 -1
- package/cjs/graph/animation/animation/rotate.js +5 -5
- package/cjs/graph/animation/animation/rotate.js.map +1 -1
- package/cjs/graph/animation/animation/scale.js +5 -5
- package/cjs/graph/animation/animation/scale.js.map +1 -1
- package/cjs/graph/animation/animation/update.js +2 -2
- package/cjs/graph/animation/animation/update.js.map +1 -1
- package/cjs/graph/animation/animator.js +6 -1
- package/cjs/graph/animation/animator.js.map +1 -1
- package/cjs/graph/animation/morph.d.ts +12 -2
- package/cjs/graph/animation/morph.js +163 -76
- package/cjs/graph/animation/morph.js.map +1 -1
- package/cjs/graph/attributes/line.d.ts +1 -0
- package/cjs/graph/attributes/line.js +17 -5
- package/cjs/graph/attributes/line.js.map +1 -1
- package/cjs/graph/canvas-renderer.d.ts +1 -1
- package/cjs/graph/canvas-renderer.js +4 -4
- package/cjs/graph/canvas-renderer.js.map +1 -1
- package/cjs/graph/constants.d.ts +1 -0
- package/cjs/graph/constants.js +2 -2
- package/cjs/graph/constants.js.map +1 -1
- package/cjs/graph/element.d.ts +2 -1
- package/cjs/graph/element.js +22 -20
- package/cjs/graph/element.js.map +1 -1
- package/cjs/graph/glyph-element.js +6 -7
- package/cjs/graph/glyph-element.js.map +1 -1
- package/cjs/graph/layout/layout.d.ts +0 -1
- package/cjs/graph/layout/layout.js +2 -8
- package/cjs/graph/layout/layout.js.map +1 -1
- package/cjs/graph/mark/graphic.js +8 -14
- package/cjs/graph/mark/graphic.js.map +1 -1
- package/cjs/graph/util/element.d.ts +2 -0
- package/cjs/graph/util/element.js +10 -0
- package/cjs/graph/util/element.js.map +1 -0
- package/cjs/graph/util/point.js +26 -10
- package/cjs/graph/util/point.js.map +1 -1
- package/cjs/index.d.ts +1 -8
- package/cjs/index.js +2 -66
- package/cjs/index.js.map +1 -1
- package/cjs/interactions/brush-base.js +2 -1
- package/cjs/interactions/brush-filter.js +1 -2
- package/cjs/interactions/fish-eye.js +2 -1
- package/cjs/interactions/index.js +1 -2
- package/cjs/interactions/tooltip.js +1 -1
- package/cjs/parse/event.d.ts +2 -0
- package/cjs/parse/event.js +10 -4
- package/cjs/parse/event.js.map +1 -1
- package/cjs/parse/util.js.map +1 -1
- package/cjs/transforms/mark/mark-overlap.js +6 -6
- package/cjs/transforms/mark/mark-overlap.js.map +1 -1
- package/cjs/types/animate.d.ts +1 -0
- package/cjs/types/animate.js.map +1 -1
- package/cjs/types/element.d.ts +5 -1
- package/cjs/types/element.js.map +1 -1
- package/cjs/types/morph.d.ts +2 -1
- package/cjs/types/morph.js.map +1 -1
- package/cjs/types/renderer.d.ts +1 -6
- package/cjs/types/renderer.js.map +1 -1
- package/cjs/view/View.d.ts +6 -3
- package/cjs/view/View.js +105 -52
- package/cjs/view/View.js.map +1 -1
- package/cjs/view/animate.js +1 -2
- package/cjs/view/animate.js.map +1 -1
- package/cjs/view/constants.d.ts +0 -2
- package/cjs/view/constants.js +2 -3
- package/cjs/view/constants.js.map +1 -1
- package/cjs/view/events.d.ts +1 -0
- package/cjs/view/events.js +17 -3
- package/cjs/view/events.js.map +1 -1
- package/cjs/view/glyph.d.ts +0 -4
- package/cjs/view/glyph.js +3 -12
- package/cjs/view/glyph.js.map +1 -1
- package/cjs/view/grammar-record.js +2 -3
- package/cjs/view/grammar-record.js.map +1 -1
- package/cjs/view/group.js +3 -3
- package/cjs/view/group.js.map +1 -1
- package/cjs/view/mark.d.ts +0 -2
- package/cjs/view/mark.js +28 -31
- package/cjs/view/mark.js.map +1 -1
- package/es/component/axis.d.ts +0 -2
- package/es/component/axis.js +0 -10
- package/es/component/axis.js.map +1 -1
- package/es/component/grid.d.ts +0 -2
- package/es/component/grid.js +0 -10
- package/es/component/grid.js.map +1 -1
- package/es/component/index.d.ts +2 -2
- package/es/component/index.js +2 -2
- package/es/component/index.js.map +1 -1
- package/es/core/factory.d.ts +1 -8
- package/es/core/factory.js +1 -8
- package/es/core/factory.js.map +1 -1
- package/es/glyph/boxplot.js +2 -4
- package/es/glyph/boxplot.js.map +1 -1
- package/es/glyph/link-path.js +2 -4
- package/es/glyph/link-path.js.map +1 -1
- package/es/glyph/ripple.js +1 -3
- package/es/glyph/ripple.js.map +1 -1
- package/es/glyph/tree-path.js +2 -4
- package/es/glyph/tree-path.js.map +1 -1
- package/es/glyph/violin.js +2 -4
- package/es/glyph/violin.js.map +1 -1
- package/es/glyph/wave.js +1 -3
- package/es/glyph/wave.js.map +1 -1
- package/es/graph/animation/animation/fade.js +4 -4
- package/es/graph/animation/animation/fade.js.map +1 -1
- package/es/graph/animation/animation/grow-cartesian.js +14 -14
- package/es/graph/animation/animation/grow-cartesian.js.map +1 -1
- package/es/graph/animation/animation/grow-interval.js +9 -9
- package/es/graph/animation/animation/grow-interval.js.map +1 -1
- package/es/graph/animation/animation/grow-points.js +9 -9
- package/es/graph/animation/animation/grow-points.js.map +1 -1
- package/es/graph/animation/animation/grow-polar.js +24 -24
- package/es/graph/animation/animation/grow-polar.js.map +1 -1
- package/es/graph/animation/animation/move.js +6 -6
- package/es/graph/animation/animation/move.js.map +1 -1
- package/es/graph/animation/animation/rotate.js +4 -4
- package/es/graph/animation/animation/rotate.js.map +1 -1
- package/es/graph/animation/animation/scale.js +5 -5
- package/es/graph/animation/animation/scale.js.map +1 -1
- package/es/graph/animation/animation/update.js +3 -1
- package/es/graph/animation/animation/update.js.map +1 -1
- package/es/graph/animation/animator.js +6 -1
- package/es/graph/animation/animator.js.map +1 -1
- package/es/graph/animation/morph.d.ts +12 -2
- package/es/graph/animation/morph.js +159 -72
- package/es/graph/animation/morph.js.map +1 -1
- package/es/graph/attributes/line.d.ts +1 -0
- package/es/graph/attributes/line.js +14 -3
- package/es/graph/attributes/line.js.map +1 -1
- package/es/graph/canvas-renderer.d.ts +1 -1
- package/es/graph/canvas-renderer.js +5 -5
- package/es/graph/canvas-renderer.js.map +1 -1
- package/es/graph/constants.d.ts +1 -0
- package/es/graph/constants.js +2 -0
- package/es/graph/constants.js.map +1 -1
- package/es/graph/element.d.ts +2 -1
- package/es/graph/element.js +24 -20
- package/es/graph/element.js.map +1 -1
- package/es/graph/glyph-element.js +8 -6
- package/es/graph/glyph-element.js.map +1 -1
- package/es/graph/layout/layout.d.ts +0 -1
- package/es/graph/layout/layout.js +0 -6
- package/es/graph/layout/layout.js.map +1 -1
- package/es/graph/mark/graphic.js +7 -13
- package/es/graph/mark/graphic.js.map +1 -1
- package/es/graph/util/element.d.ts +2 -0
- package/es/graph/util/element.js +8 -0
- package/es/graph/util/element.js.map +1 -0
- package/es/graph/util/point.js +26 -10
- package/es/graph/util/point.js.map +1 -1
- package/es/index.d.ts +1 -8
- package/es/index.js +1 -29
- package/es/index.js.map +1 -1
- package/es/interactions/element-active.js +2 -1
- package/es/interactions/element-highlight-by-group.js +1 -2
- package/es/interactions/fish-eye.js +1 -1
- package/es/parse/event.d.ts +2 -0
- package/es/parse/event.js +7 -3
- package/es/parse/event.js.map +1 -1
- package/es/parse/option.js +2 -1
- package/es/parse/scale.js +1 -2
- package/es/parse/util.js.map +1 -1
- package/es/transforms/mark/mark-overlap.js +6 -6
- package/es/transforms/mark/mark-overlap.js.map +1 -1
- package/es/types/animate.d.ts +1 -0
- package/es/types/animate.js.map +1 -1
- package/es/types/element.d.ts +5 -1
- package/es/types/element.js.map +1 -1
- package/es/types/morph.d.ts +2 -1
- package/es/types/morph.js.map +1 -1
- package/es/types/renderer.d.ts +1 -6
- package/es/types/renderer.js.map +1 -1
- package/es/view/View.d.ts +6 -3
- package/es/view/View.js +114 -53
- package/es/view/View.js.map +1 -1
- package/es/view/animate.js +1 -2
- package/es/view/animate.js.map +1 -1
- package/es/view/constants.d.ts +0 -2
- package/es/view/constants.js +0 -4
- package/es/view/constants.js.map +1 -1
- package/es/view/events.d.ts +1 -0
- package/es/view/events.js +15 -1
- package/es/view/events.js.map +1 -1
- package/es/view/glyph.d.ts +0 -4
- package/es/view/glyph.js +0 -11
- package/es/view/glyph.js.map +1 -1
- package/es/view/grammar-record.js +2 -3
- package/es/view/grammar-record.js.map +1 -1
- package/es/view/group.js +4 -2
- package/es/view/group.js.map +1 -1
- package/es/view/mark.d.ts +0 -2
- package/es/view/mark.js +30 -32
- package/es/view/mark.js.map +1 -1
- package/package.json +9 -9
- package/cjs/graph/view-diff.d.ts +0 -8
- package/cjs/graph/view-diff.js +0 -93
- package/cjs/graph/view-diff.js.map +0 -1
- package/cjs/view/mark-animate-mixin.d.ts +0 -1
- package/cjs/view/mark-animate-mixin.js +0 -29
- package/cjs/view/mark-animate-mixin.js.map +0 -1
- package/cjs/view/view-animate-mixin.d.ts +0 -1
- package/cjs/view/view-animate-mixin.js +0 -26
- package/cjs/view/view-animate-mixin.js.map +0 -1
- package/cjs/view/view-event-mixin.d.ts +0 -1
- package/cjs/view/view-event-mixin.js +0 -92
- package/cjs/view/view-event-mixin.js.map +0 -1
- package/cjs/view/view-morph-mixin.d.ts +0 -1
- package/cjs/view/view-morph-mixin.js +0 -32
- package/cjs/view/view-morph-mixin.js.map +0 -1
- package/es/graph/view-diff.d.ts +0 -8
- package/es/graph/view-diff.js +0 -89
- package/es/graph/view-diff.js.map +0 -1
- package/es/view/mark-animate-mixin.d.ts +0 -1
- package/es/view/mark-animate-mixin.js +0 -25
- package/es/view/mark-animate-mixin.js.map +0 -1
- package/es/view/view-animate-mixin.d.ts +0 -1
- package/es/view/view-animate-mixin.js +0 -16
- package/es/view/view-animate-mixin.js.map +0 -1
- package/es/view/view-event-mixin.d.ts +0 -1
- package/es/view/view-event-mixin.js +0 -90
- package/es/view/view-event-mixin.js.map +0 -1
- package/es/view/view-morph-mixin.d.ts +0 -1
- package/es/view/view-morph-mixin.js +0 -22
- package/es/view/view-morph-mixin.js.map +0 -1
package/es/view/View.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { EventEmitter, debounce, isString, getContainerSize, Logger, array, isNil
|
|
1
|
+
import { EventEmitter, debounce, isObject, isString, getContainerSize, Logger, array, isNil } from "@visactor/vutils";
|
|
2
2
|
|
|
3
3
|
import { vglobal } from "@visactor/vrender-core";
|
|
4
4
|
|
|
5
5
|
import { Data } from "./data";
|
|
6
6
|
|
|
7
|
+
import { initializeEventConfig, permit, prevent } from "./events";
|
|
8
|
+
|
|
7
9
|
import Dataflow from "./dataflow";
|
|
8
10
|
|
|
9
11
|
import { traverseMarkTree } from "../graph/mark-tree";
|
|
@@ -14,13 +16,15 @@ import CanvasRenderer from "../graph/canvas-renderer";
|
|
|
14
16
|
|
|
15
17
|
import getExtendedEvents from "../graph/util/events-extend";
|
|
16
18
|
|
|
17
|
-
import { BROWSER, SIGNAL_WIDTH, SIGNAL_HEIGHT, SIGNAL_PADDING, SIGNAL_AUTOFIT, SIGNAL_VIEW_WIDTH, SIGNAL_VIEW_HEIGHT, EVENT_SOURCE_VIEW,
|
|
19
|
+
import { BROWSER, NO_TRAP, SIGNAL_WIDTH, SIGNAL_HEIGHT, SIGNAL_PADDING, SIGNAL_AUTOFIT, SIGNAL_VIEW_WIDTH, SIGNAL_VIEW_HEIGHT, EVENT_SOURCE_VIEW, EVENT_SOURCE_WINDOW, SIGNAL_VIEW_BOX } from "./constants";
|
|
18
20
|
|
|
19
21
|
import { Signal } from "./signal";
|
|
20
22
|
|
|
21
23
|
import { BuiltInSignalID, builtInSignals, normalizeMarkTree, normalizeRunningConfig, normalizePadding } from "../parse/view";
|
|
22
24
|
|
|
23
|
-
import {
|
|
25
|
+
import { parseHandler, parseEventSelector, generateFilterByMark, ID_PREFIX, NAME_PREFIX } from "../parse/event";
|
|
26
|
+
|
|
27
|
+
import { isGrammar, parseReference } from "../parse/util";
|
|
24
28
|
|
|
25
29
|
import { configureEnvironment } from "../graph/util/env";
|
|
26
30
|
|
|
@@ -28,8 +32,16 @@ import { GroupMark } from "./group";
|
|
|
28
32
|
|
|
29
33
|
import { Mark } from "./mark";
|
|
30
34
|
|
|
35
|
+
import { defaultDoLayout } from "../graph/layout/layout";
|
|
36
|
+
|
|
37
|
+
import { GlyphMark } from "./glyph";
|
|
38
|
+
|
|
39
|
+
import { Morph } from "../graph/animation/morph";
|
|
40
|
+
|
|
31
41
|
import { RecordedGrammars, RecordedTreeGrammars } from "./grammar-record";
|
|
32
42
|
|
|
43
|
+
import { ViewAnimate } from "./animate";
|
|
44
|
+
|
|
33
45
|
import { ComponentEnum, HOOK_EVENT, LayoutState, GrammarMarkType } from "../graph/enums";
|
|
34
46
|
|
|
35
47
|
import { Text } from "../semantic-marks/text";
|
|
@@ -42,8 +54,6 @@ import { Component } from "./component";
|
|
|
42
54
|
|
|
43
55
|
import { isMarkType, removeGraphicItem } from "../graph/util/graphic";
|
|
44
56
|
|
|
45
|
-
import { ViewDiff } from "../graph/view-diff";
|
|
46
|
-
|
|
47
57
|
export default class View extends EventEmitter {
|
|
48
58
|
static useRegisters(comps) {
|
|
49
59
|
comps.forEach((fn => {
|
|
@@ -144,8 +154,7 @@ export default class View extends EventEmitter {
|
|
|
144
154
|
break;
|
|
145
155
|
|
|
146
156
|
case GrammarMarkType.glyph:
|
|
147
|
-
|
|
148
|
-
GlyphMark && (mark = new GlyphMark(this, null == markOptions ? void 0 : markOptions.glyphType, groupMark));
|
|
157
|
+
mark = new GlyphMark(this, null == markOptions ? void 0 : markOptions.glyphType, groupMark);
|
|
149
158
|
break;
|
|
150
159
|
|
|
151
160
|
case GrammarMarkType.component:
|
|
@@ -251,7 +260,7 @@ export default class View extends EventEmitter {
|
|
|
251
260
|
})), this;
|
|
252
261
|
}
|
|
253
262
|
parseSpec(spec) {
|
|
254
|
-
var _a, _b, _c, _d, _e, _f
|
|
263
|
+
var _a, _b, _c, _d, _e, _f;
|
|
255
264
|
if (this.emit(HOOK_EVENT.BEFORE_PARSE_VIEW), this._spec = spec, normalizeMarkTree(spec),
|
|
256
265
|
spec.theme ? this.theme(spec.theme) : this.theme(ThemeManager.getDefaultTheme()),
|
|
257
266
|
spec.width && this.width(spec.width), spec.height && this.height(spec.height), this.padding(null !== (_b = null !== (_a = spec.padding) && void 0 !== _a ? _a : this._options.padding) && void 0 !== _b ? _b : this._theme.padding),
|
|
@@ -279,13 +288,11 @@ export default class View extends EventEmitter {
|
|
|
279
288
|
})), spec.marks && spec.marks.length && spec.marks.forEach((mark => {
|
|
280
289
|
this.parseMarkSpec(mark);
|
|
281
290
|
})), spec.events && spec.events.length && spec.events.forEach((eventConfig => {
|
|
282
|
-
|
|
283
|
-
null === (_b = this.event) || void 0 === _b || _b.call(this, eventConfig);
|
|
291
|
+
this.event(eventConfig);
|
|
284
292
|
})), spec.interactions && spec.interactions.length && spec.interactions.forEach((interaction => {
|
|
285
293
|
this.interaction(interaction.type, interaction);
|
|
286
|
-
})), !1 === spec.animation ?
|
|
287
|
-
this.
|
|
288
|
-
this;
|
|
294
|
+
})), !1 === spec.animation ? this.animate.disable() : this.animate.enable(), this.emit(HOOK_EVENT.AFTER_PARSE_VIEW),
|
|
295
|
+
this._needBuildLayoutTree = !0, this._layoutState = LayoutState.before, this;
|
|
289
296
|
}
|
|
290
297
|
updateSpec(spec) {
|
|
291
298
|
return this.removeAllInteractions(), this.removeAllGrammars(), this.parseSpec(spec);
|
|
@@ -405,7 +412,7 @@ export default class View extends EventEmitter {
|
|
|
405
412
|
}
|
|
406
413
|
doLayout() {
|
|
407
414
|
var _a;
|
|
408
|
-
const doLayout = this._options.doLayout ||
|
|
415
|
+
const doLayout = this._options.doLayout || defaultDoLayout;
|
|
409
416
|
doLayout && (null === (_a = this._layoutMarks) || void 0 === _a ? void 0 : _a.length) && (this.emit(HOOK_EVENT.BEFORE_DO_LAYOUT),
|
|
410
417
|
doLayout(this._layoutMarks, this._options, this), this.emit(HOOK_EVENT.AFTER_DO_LAYOUT));
|
|
411
418
|
}
|
|
@@ -428,11 +435,11 @@ export default class View extends EventEmitter {
|
|
|
428
435
|
return this.evaluate(runningConfig), this;
|
|
429
436
|
}
|
|
430
437
|
doRender(immediately) {
|
|
431
|
-
this.emit(HOOK_EVENT.BEFORE_DO_RENDER), this.renderer && (
|
|
438
|
+
this.emit(HOOK_EVENT.BEFORE_DO_RENDER), this.renderer && (this._progressiveMarks || this.animate.animate(),
|
|
432
439
|
this.renderer.render(immediately), this.handleRenderEnd()), this.emit(HOOK_EVENT.AFTER_DO_RENDER);
|
|
433
440
|
}
|
|
434
441
|
evaluate(runningConfig) {
|
|
435
|
-
var _a,
|
|
442
|
+
var _a, _b;
|
|
436
443
|
const normalizedRunningConfig = normalizeRunningConfig(runningConfig), grammarWillDetach = this._cachedGrammars.size() > 0;
|
|
437
444
|
grammarWillDetach && (this.reuseCachedGrammars(normalizedRunningConfig), this.detachCachedGrammar());
|
|
438
445
|
const hasResize = this._resizeRenderer(), hasUpdate = this._dataflow.hasCommitted();
|
|
@@ -441,28 +448,28 @@ export default class View extends EventEmitter {
|
|
|
441
448
|
this._needBuildLayoutTree = !1), this._layoutState && (this._layoutState = LayoutState.layouting,
|
|
442
449
|
this.doLayout(), this._dataflow.hasCommitted() && (this._layoutState = LayoutState.reevaluate,
|
|
443
450
|
this._dataflow.evaluate()), this._layoutState = LayoutState.after, (null === (_a = this._layoutMarks) || void 0 === _a ? void 0 : _a.length) && this.handleLayoutEnd()),
|
|
444
|
-
this._layoutState = null, this.findProgressiveMarks(), this._resizeRenderer(), null === (
|
|
445
|
-
|
|
446
|
-
|
|
451
|
+
this._layoutState = null, this.findProgressiveMarks(), this._resizeRenderer(), null === (_b = this._willMorphMarks) || void 0 === _b || _b.forEach((morphMarks => {
|
|
452
|
+
this._morph.morph(morphMarks.prev, morphMarks.next, normalizedRunningConfig);
|
|
453
|
+
})), this._willMorphMarks = null, this.releaseCachedGrammars(normalizedRunningConfig),
|
|
454
|
+
this.doRender(!0), this.doPreProgressive(), this) : this;
|
|
447
455
|
}
|
|
448
456
|
reuseCachedGrammars(runningConfig) {
|
|
449
|
-
if (runningConfig.reuse) {
|
|
457
|
+
if (this._willMorphMarks || (this._willMorphMarks = []), runningConfig.reuse) {
|
|
450
458
|
const reuseDiffUpdate = diff => {
|
|
451
459
|
diff.next.reuse(diff.prev), diff.prev.detachAll(), diff.prev.clear(), this._cachedGrammars.unrecord(diff.prev);
|
|
452
460
|
};
|
|
453
|
-
this.
|
|
454
|
-
this.
|
|
455
|
-
this.
|
|
456
|
-
this.
|
|
461
|
+
this._morph.diffGrammar(this._cachedGrammars.getAllSignals(), this.grammars.getAllSignals().filter((signal => !BuiltInSignalID.includes(signal.id())))).update.forEach(reuseDiffUpdate);
|
|
462
|
+
this._morph.diffGrammar(this._cachedGrammars.getAllData(), this.grammars.getAllData()).update.forEach(reuseDiffUpdate);
|
|
463
|
+
this._morph.diffGrammar(this._cachedGrammars.getAllScales(), this.grammars.getAllScales()).update.forEach(reuseDiffUpdate);
|
|
464
|
+
this._morph.diffGrammar(this._cachedGrammars.getAllCoordinates(), this.grammars.getAllCoordinates()).update.forEach(reuseDiffUpdate);
|
|
457
465
|
}
|
|
458
|
-
this.
|
|
459
|
-
var _b;
|
|
466
|
+
this._morph.diffMark(this._cachedGrammars.getAllMarks(), this.grammars.getAllMarks().filter((mark => "root" !== mark.id())), runningConfig).update.forEach((diff => {
|
|
460
467
|
const matched = 1 === diff.prev.length && 1 === diff.next.length && diff.prev[0].markType === diff.next[0].markType, enableMarkMorphConfig = diff.prev.every((mark => mark.getMorphConfig().morph)) && diff.next.every((mark => mark.getMorphConfig().morph));
|
|
461
468
|
matched && runningConfig.reuse ? (diff.next[0].reuse(diff.prev[0]), diff.prev[0].detachAll(),
|
|
462
|
-
diff.prev[0].clear(), this._cachedGrammars.unrecord(diff.prev[0])) : (runningConfig.morph && enableMarkMorphConfig || runningConfig.morphAll) &&
|
|
469
|
+
diff.prev[0].clear(), this._cachedGrammars.unrecord(diff.prev[0])) : (runningConfig.morph && enableMarkMorphConfig || runningConfig.morphAll) && this._willMorphMarks.push({
|
|
463
470
|
prev: diff.prev,
|
|
464
471
|
next: diff.next
|
|
465
|
-
})
|
|
472
|
+
});
|
|
466
473
|
}));
|
|
467
474
|
}
|
|
468
475
|
detachCachedGrammar() {
|
|
@@ -480,11 +487,10 @@ export default class View extends EventEmitter {
|
|
|
480
487
|
}));
|
|
481
488
|
const markNodes = this._cachedGrammars.getAllMarkNodes();
|
|
482
489
|
markNodes.forEach((node => {
|
|
483
|
-
|
|
484
|
-
null === (_a = node.mark.animate) || void 0 === _a || _a.stop(), runningConfig.enableExitAnimation && this.animate && this.animate.animateAddition(node.mark);
|
|
490
|
+
node.mark.animate.stop(), runningConfig.enableExitAnimation && this.animate.animateAddition(node.mark);
|
|
485
491
|
}));
|
|
486
492
|
const releaseUp = node => {
|
|
487
|
-
if (node.mark.view &&
|
|
493
|
+
if (node.mark.view && 0 === node.mark.animate.getAnimatorCount() && (!node.children || 0 === node.children.length)) {
|
|
488
494
|
node.mark.release();
|
|
489
495
|
const parent = node.parent;
|
|
490
496
|
parent && (node.parent.children = node.parent.children.filter((n => n !== node)),
|
|
@@ -493,8 +499,8 @@ export default class View extends EventEmitter {
|
|
|
493
499
|
};
|
|
494
500
|
markNodes.forEach((node => {
|
|
495
501
|
const mark = node.mark;
|
|
496
|
-
|
|
497
|
-
|
|
502
|
+
0 === mark.animate.getAnimatorCount() ? releaseUp(node) : mark.addEventListener("animationEnd", (() => {
|
|
503
|
+
0 === mark.animate.getAnimatorCount() && releaseUp(node);
|
|
498
504
|
}));
|
|
499
505
|
})), this._cachedGrammars.clear();
|
|
500
506
|
}
|
|
@@ -562,6 +568,73 @@ export default class View extends EventEmitter {
|
|
|
562
568
|
height: height
|
|
563
569
|
}), !0);
|
|
564
570
|
}
|
|
571
|
+
bindEvents(eventSpec) {
|
|
572
|
+
if (this._eventConfig.disable) return;
|
|
573
|
+
const {type: evtType, filter: filter, callback: callback, throttle: throttle, debounce: debounce, consume: consume, target: target, dependency: dependency} = eventSpec, eventSelector = parseEventSelector(evtType);
|
|
574
|
+
if (!eventSelector) return;
|
|
575
|
+
const {source: source, type: type} = eventSelector, markFilter = generateFilterByMark(eventSelector), validateSignals = (Array.isArray(target) && target.length ? target.map((entry => ({
|
|
576
|
+
signal: this.getSignalById(entry.target),
|
|
577
|
+
callback: entry.callback
|
|
578
|
+
}))) : [ {
|
|
579
|
+
signal: isString(target) ? this.getSignalById(target) : null,
|
|
580
|
+
callback: callback
|
|
581
|
+
} ]).filter((entry => entry.signal || entry.callback)), refs = parseReference(dependency, this), send = parseHandler(((evt, element) => {
|
|
582
|
+
const needPreventDefault = source === EVENT_SOURCE_VIEW && prevent(this._eventConfig, type) || consume && (void 0 === evt.cancelable || evt.cancelable);
|
|
583
|
+
source === EVENT_SOURCE_WINDOW && (evt = getExtendedEvents(this, evt, element, type, EVENT_SOURCE_WINDOW));
|
|
584
|
+
let hasCommitted = !1;
|
|
585
|
+
if ((!filter || filter(evt)) && (!markFilter || markFilter(element)) && validateSignals.length) {
|
|
586
|
+
const params = refs.reduce(((params, ref) => (params[ref.id()] = ref.output(), params)), {});
|
|
587
|
+
validateSignals.forEach((entry => {
|
|
588
|
+
if (entry.callback && entry.signal) {
|
|
589
|
+
entry.signal.set(entry.callback(evt, params)) && (this.commit(entry.signal), hasCommitted = !0);
|
|
590
|
+
} else entry.callback ? entry.callback(evt, params) : (this.commit(entry.signal),
|
|
591
|
+
hasCommitted = !0);
|
|
592
|
+
}));
|
|
593
|
+
}
|
|
594
|
+
needPreventDefault && evt.preventDefault(), consume && evt.stopPropagation(), hasCommitted && this.run();
|
|
595
|
+
}), {
|
|
596
|
+
throttle: throttle,
|
|
597
|
+
debounce: debounce
|
|
598
|
+
});
|
|
599
|
+
if (source === EVENT_SOURCE_VIEW) {
|
|
600
|
+
if (permit(this._eventConfig, EVENT_SOURCE_VIEW, type)) return this.addEventListener(type, send, NO_TRAP),
|
|
601
|
+
() => {
|
|
602
|
+
this.removeEventListener(type, send);
|
|
603
|
+
};
|
|
604
|
+
} else if (source === EVENT_SOURCE_WINDOW) return vglobal.addEventListener(type, send),
|
|
605
|
+
this._eventListeners.push({
|
|
606
|
+
type: type,
|
|
607
|
+
source: vglobal,
|
|
608
|
+
handler: send
|
|
609
|
+
}), () => {
|
|
610
|
+
vglobal.removeEventListener(type, send);
|
|
611
|
+
const index = this._eventListeners.findIndex((entry => entry.type === type && entry.source === vglobal && entry.handler === send));
|
|
612
|
+
index >= 0 && this._eventListeners.splice(index, 1);
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
event(eventSpec) {
|
|
616
|
+
if ("between" in eventSpec) {
|
|
617
|
+
const [starEvent, endEvent] = eventSpec.between, id = `${starEvent.type}-${eventSpec.type}-${endEvent.type}`;
|
|
618
|
+
let unbindEndEvent;
|
|
619
|
+
this.bindEvents(Object.assign({}, starEvent, {
|
|
620
|
+
callback: () => {
|
|
621
|
+
if (this._eventCache || (this._eventCache = {}), !this._eventCache[id]) {
|
|
622
|
+
const unbindEvent = this.bindEvents(eventSpec);
|
|
623
|
+
this._eventCache[id] = unbindEvent;
|
|
624
|
+
}
|
|
625
|
+
unbindEndEvent || (unbindEndEvent = this.bindEvents(Object.assign({}, endEvent, {
|
|
626
|
+
callback: () => {
|
|
627
|
+
this._eventCache[id] && (this._eventCache[id](), this._eventCache[id] = null);
|
|
628
|
+
}
|
|
629
|
+
})));
|
|
630
|
+
}
|
|
631
|
+
}));
|
|
632
|
+
} else "merge" in eventSpec ? eventSpec.merge.forEach((entry => {
|
|
633
|
+
const singleEvent = Object.assign({}, eventSpec);
|
|
634
|
+
isString(entry) ? singleEvent.type = entry : isObject(entry) && Object.assign(singleEvent, entry),
|
|
635
|
+
singleEvent.debounce = 50, this.bindEvents(singleEvent);
|
|
636
|
+
})) : this.bindEvents(eventSpec);
|
|
637
|
+
}
|
|
565
638
|
interaction(type, spec) {
|
|
566
639
|
const interaction = Factory.createInteraction(type, this, spec);
|
|
567
640
|
return interaction && (interaction.bind(), this._boundInteractions || (this._boundInteractions = []),
|
|
@@ -584,17 +657,6 @@ export default class View extends EventEmitter {
|
|
|
584
657
|
instance.unbind();
|
|
585
658
|
})), this._boundInteractions = null), this;
|
|
586
659
|
}
|
|
587
|
-
initializeEventConfig(config) {
|
|
588
|
-
const eventsConfig = Object.assign({
|
|
589
|
-
defaults: {}
|
|
590
|
-
}, config), unpack = (obj, keys) => {
|
|
591
|
-
keys.forEach((k => {
|
|
592
|
-
isArray(obj[k]) && (obj[k] = obj[k].reduce(((set, key) => (set[key] = !0, set)), {}));
|
|
593
|
-
}));
|
|
594
|
-
};
|
|
595
|
-
return unpack(eventsConfig.defaults, [ "prevent", "allow" ]), unpack(eventsConfig, [ EVENT_SOURCE_VIEW, EVENT_SOURCE_WINDOW ]),
|
|
596
|
-
eventsConfig;
|
|
597
|
-
}
|
|
598
660
|
initEvent() {
|
|
599
661
|
const stage = this.renderer.stage();
|
|
600
662
|
stage && stage.on("*", this.delegateEvent);
|
|
@@ -617,15 +679,15 @@ export default class View extends EventEmitter {
|
|
|
617
679
|
this.renderer = new CanvasRenderer(this), this.renderer.initialize(width, height, this._options, this._eventConfig).background(this._background);
|
|
618
680
|
}
|
|
619
681
|
initialize() {
|
|
620
|
-
var _a
|
|
682
|
+
var _a;
|
|
621
683
|
this.grammars = new RecordedGrammars((grammar => grammar.id()), ((key, grammar) => this.logger.warn(`Grammar id '${key}' has been occupied`, grammar))),
|
|
622
684
|
this._cachedGrammars = new RecordedTreeGrammars((grammar => grammar.id())), this._options.logger && Logger.setInstance(this._options.logger),
|
|
623
685
|
this.logger = Logger.getInstance(null !== (_a = this._options.logLevel) && void 0 !== _a ? _a : 0),
|
|
624
|
-
this._dataflow = new Dataflow, this.animate =
|
|
625
|
-
this.
|
|
686
|
+
this._dataflow = new Dataflow, this.animate = new ViewAnimate(this), this._morph = new Morph,
|
|
687
|
+
this._options.hooks && (Object.keys(this._options.hooks).forEach((key => {
|
|
626
688
|
this.on(key, this._options.hooks[key]);
|
|
627
689
|
})), this.hooks = this._options.hooks), this.container = null, this.renderer = null,
|
|
628
|
-
this._eventListeners = [], this._eventConfig =
|
|
690
|
+
this._eventListeners = [], this._eventConfig = initializeEventConfig(this._options.eventConfig),
|
|
629
691
|
this._theme = this._options.disableTheme ? null : ThemeManager.getDefaultTheme(),
|
|
630
692
|
this.parseBuiltIn(), configureEnvironment(this._options), this.initializeRenderer(),
|
|
631
693
|
this._eventConfig.disable || this.initEvent(), this._bindResizeEvent(), this._needBuildLayoutTree = !0,
|
|
@@ -663,14 +725,13 @@ export default class View extends EventEmitter {
|
|
|
663
725
|
})), this._progressiveMarks = null);
|
|
664
726
|
}
|
|
665
727
|
release() {
|
|
666
|
-
var _a, _b, _c
|
|
728
|
+
var _a, _b, _c;
|
|
667
729
|
this.removeAllInteractions(), this.releaseStageEvent(), this._unBindResizeEvent(),
|
|
668
730
|
this.clearProgressive(), Factory.unregisterRuntimeTransforms(), Logger.setInstance(null),
|
|
669
|
-
|
|
670
|
-
this.
|
|
671
|
-
null === (_c = null === (_b = this.renderer) || void 0 === _b ? void 0 : _b.release) || void 0 === _c || _c.call(_b),
|
|
731
|
+
this.animate.stop(), this.grammars.release(), this._cachedGrammars.release(), this._dataflow.release(),
|
|
732
|
+
this._dataflow = null, null === (_b = null === (_a = this.renderer) || void 0 === _a ? void 0 : _a.release) || void 0 === _b || _b.call(_a),
|
|
672
733
|
this.renderer = null, this._boundInteractions = null, this.removeAllListeners(),
|
|
673
|
-
null === (
|
|
734
|
+
null === (_c = this._eventListeners) || void 0 === _c || _c.forEach((listener => {
|
|
674
735
|
listener.source.removeEventListener(listener.type, listener.handler);
|
|
675
736
|
})), this._eventListeners = null;
|
|
676
737
|
}
|