squarified 0.6.1 → 1.0.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/{dom-event-CxIxc4YC.js → dom-event-ClwTQnot.js} +14 -15
- package/dist/{dom-event-CKb3Ko4-.mjs → dom-event-DrYYfglv.mjs} +14 -15
- package/dist/{index-Bb8ZzMCD.d.ts → index-Bks7tGiV.d.ts} +1 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +2 -2
- package/dist/plugin.d.mts +2 -1
- package/dist/plugin.d.ts +2 -1
- package/dist/plugin.js +40 -26
- package/dist/plugin.mjs +40 -26
- package/package.json +1 -1
|
@@ -1095,8 +1095,8 @@ function squarify(data, rect, config, scale = 1) {
|
|
|
1095
1095
|
const totalArea = rect.w * rect.h;
|
|
1096
1096
|
const containerSize = Math.min(rect.w, rect.h);
|
|
1097
1097
|
const scaleFactor = Math.max(0.5, Math.min(1, containerSize / 800));
|
|
1098
|
-
|
|
1099
|
-
const minRenderableSize = Math.max(
|
|
1098
|
+
const baseMinSize = 20;
|
|
1099
|
+
const minRenderableSize = Math.max(8, baseMinSize / Math.sqrt(scale));
|
|
1100
1100
|
const minRenderableArea = minRenderableSize * minRenderableSize;
|
|
1101
1101
|
const scaledGap = config.rectGap * scaleFactor;
|
|
1102
1102
|
const scaledRadius = config.rectRadius * scaleFactor;
|
|
@@ -1364,17 +1364,17 @@ class Component extends Schedule {
|
|
|
1364
1364
|
}
|
|
1365
1365
|
return result;
|
|
1366
1366
|
}
|
|
1367
|
-
getViewportAABB(matrixE, matrixF
|
|
1367
|
+
getViewportAABB(matrixE, matrixF) {
|
|
1368
1368
|
const { width, height } = this.render.options;
|
|
1369
|
-
const
|
|
1370
|
-
const
|
|
1371
|
-
const
|
|
1372
|
-
const
|
|
1369
|
+
const viewportX = -matrixE;
|
|
1370
|
+
const viewportY = -matrixF;
|
|
1371
|
+
const viewportWidth = width;
|
|
1372
|
+
const viewportHeight = height;
|
|
1373
1373
|
return {
|
|
1374
|
-
x:
|
|
1375
|
-
y:
|
|
1376
|
-
width:
|
|
1377
|
-
height:
|
|
1374
|
+
x: viewportX,
|
|
1375
|
+
y: viewportY,
|
|
1376
|
+
width: viewportWidth,
|
|
1377
|
+
height: viewportHeight
|
|
1378
1378
|
};
|
|
1379
1379
|
}
|
|
1380
1380
|
getAABBUnion(a, b) {
|
|
@@ -1390,8 +1390,8 @@ class Component extends Schedule {
|
|
|
1390
1390
|
};
|
|
1391
1391
|
}
|
|
1392
1392
|
handleTransformCacheInvalidation(oldMatrix, newMatrix) {
|
|
1393
|
-
const oldViewportAABB = this.getViewportAABB(oldMatrix.e, oldMatrix.f
|
|
1394
|
-
const newViewportAABB = this.getViewportAABB(newMatrix.e, newMatrix.f
|
|
1393
|
+
const oldViewportAABB = this.getViewportAABB(oldMatrix.e, oldMatrix.f);
|
|
1394
|
+
const newViewportAABB = this.getViewportAABB(newMatrix.e, newMatrix.f);
|
|
1395
1395
|
const affectedAABB = this.getAABBUnion(oldViewportAABB, newViewportAABB);
|
|
1396
1396
|
this.clearFontCacheInAABB(affectedAABB);
|
|
1397
1397
|
}
|
|
@@ -1699,10 +1699,9 @@ class DOMEvent extends Event {
|
|
|
1699
1699
|
native: e.native,
|
|
1700
1700
|
module: node
|
|
1701
1701
|
});
|
|
1702
|
-
// For MacOS
|
|
1703
1702
|
}
|
|
1704
1703
|
findRelativeNode(e) {
|
|
1705
|
-
return findRelativeNode(captureBoxXY(this.el, e.native,
|
|
1704
|
+
return findRelativeNode(captureBoxXY(this.el, e.native, 1, 1, this.matrix.e, this.matrix.f), this.component.layoutNodes);
|
|
1706
1705
|
}
|
|
1707
1706
|
}
|
|
1708
1707
|
|
|
@@ -1093,8 +1093,8 @@ function squarify(data, rect, config, scale = 1) {
|
|
|
1093
1093
|
const totalArea = rect.w * rect.h;
|
|
1094
1094
|
const containerSize = Math.min(rect.w, rect.h);
|
|
1095
1095
|
const scaleFactor = Math.max(0.5, Math.min(1, containerSize / 800));
|
|
1096
|
-
|
|
1097
|
-
const minRenderableSize = Math.max(
|
|
1096
|
+
const baseMinSize = 20;
|
|
1097
|
+
const minRenderableSize = Math.max(8, baseMinSize / Math.sqrt(scale));
|
|
1098
1098
|
const minRenderableArea = minRenderableSize * minRenderableSize;
|
|
1099
1099
|
const scaledGap = config.rectGap * scaleFactor;
|
|
1100
1100
|
const scaledRadius = config.rectRadius * scaleFactor;
|
|
@@ -1362,17 +1362,17 @@ class Component extends Schedule {
|
|
|
1362
1362
|
}
|
|
1363
1363
|
return result;
|
|
1364
1364
|
}
|
|
1365
|
-
getViewportAABB(matrixE, matrixF
|
|
1365
|
+
getViewportAABB(matrixE, matrixF) {
|
|
1366
1366
|
const { width, height } = this.render.options;
|
|
1367
|
-
const
|
|
1368
|
-
const
|
|
1369
|
-
const
|
|
1370
|
-
const
|
|
1367
|
+
const viewportX = -matrixE;
|
|
1368
|
+
const viewportY = -matrixF;
|
|
1369
|
+
const viewportWidth = width;
|
|
1370
|
+
const viewportHeight = height;
|
|
1371
1371
|
return {
|
|
1372
|
-
x:
|
|
1373
|
-
y:
|
|
1374
|
-
width:
|
|
1375
|
-
height:
|
|
1372
|
+
x: viewportX,
|
|
1373
|
+
y: viewportY,
|
|
1374
|
+
width: viewportWidth,
|
|
1375
|
+
height: viewportHeight
|
|
1376
1376
|
};
|
|
1377
1377
|
}
|
|
1378
1378
|
getAABBUnion(a, b) {
|
|
@@ -1388,8 +1388,8 @@ class Component extends Schedule {
|
|
|
1388
1388
|
};
|
|
1389
1389
|
}
|
|
1390
1390
|
handleTransformCacheInvalidation(oldMatrix, newMatrix) {
|
|
1391
|
-
const oldViewportAABB = this.getViewportAABB(oldMatrix.e, oldMatrix.f
|
|
1392
|
-
const newViewportAABB = this.getViewportAABB(newMatrix.e, newMatrix.f
|
|
1391
|
+
const oldViewportAABB = this.getViewportAABB(oldMatrix.e, oldMatrix.f);
|
|
1392
|
+
const newViewportAABB = this.getViewportAABB(newMatrix.e, newMatrix.f);
|
|
1393
1393
|
const affectedAABB = this.getAABBUnion(oldViewportAABB, newViewportAABB);
|
|
1394
1394
|
this.clearFontCacheInAABB(affectedAABB);
|
|
1395
1395
|
}
|
|
@@ -1697,10 +1697,9 @@ class DOMEvent extends Event {
|
|
|
1697
1697
|
native: e.native,
|
|
1698
1698
|
module: node
|
|
1699
1699
|
});
|
|
1700
|
-
// For MacOS
|
|
1701
1700
|
}
|
|
1702
1701
|
findRelativeNode(e) {
|
|
1703
|
-
return findRelativeNode(captureBoxXY(this.el, e.native,
|
|
1702
|
+
return findRelativeNode(captureBoxXY(this.el, e.native, 1, 1, this.matrix.e, this.matrix.f), this.component.layoutNodes);
|
|
1704
1703
|
}
|
|
1705
1704
|
}
|
|
1706
1705
|
|
|
@@ -403,16 +403,14 @@ declare class Component extends Schedule {
|
|
|
403
403
|
constructor(config: GraphicConfig, ...args: ConstructorParameters<typeof Schedule>);
|
|
404
404
|
clearFontCacheInAABB(aabb: AABB): void;
|
|
405
405
|
private getModulesInAABB;
|
|
406
|
-
getViewportAABB(matrixE: number, matrixF: number
|
|
406
|
+
getViewportAABB(matrixE: number, matrixF: number): AABB;
|
|
407
407
|
private getAABBUnion;
|
|
408
408
|
handleTransformCacheInvalidation(oldMatrix: {
|
|
409
409
|
e: number;
|
|
410
410
|
f: number;
|
|
411
|
-
a: number;
|
|
412
411
|
}, newMatrix: {
|
|
413
412
|
e: number;
|
|
414
413
|
f: number;
|
|
415
|
-
a: number;
|
|
416
414
|
}): void;
|
|
417
415
|
private isAABBIntersecting;
|
|
418
416
|
private drawBroundRect;
|
package/dist/index.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { B as BasicTreemapInstance, c as CreateTreemapOptions, D as DOMEventType, Y as DefaultMap, E as ExposedEventCallback, n as ExposedEventDefinition, o as ExposedEventMethods, x as GraphicConfig, w as GraphicFont, G as GraphicLayout, O as InheritedCollectionsWithParamter, L as LayoutModule, M as Module, N as NativeModule, k as Plugin, P as PluginContext, l as PluginHooks, p as PrimitiveEventMetadata, S as Series, e as TreemapInstance, T as TreemapOptions, K as applyCanvasTransform, f as c2m, J as createCanvasElement, F as createRoundBlock, H as createTitleText, d as createTreemap, m as definePlugin, g as findRelativeNode, h as findRelativeNodeById, i as flattenModule, j as getNodeDepth, y as hashCode, q as isClickEvent, r as isContextMenuEvent, t as isMouseEvent, X as isScrollWheelOrRightButtonOnMouseupAndDown, u as isWheelEvent, Q as mixin, A as noop, z as perferNumeric, I as raf, W as smoothFrame, s as sortChildrenByKey, U as stackMatrixTransform, V as stackMatrixTransformWithGraphAndLayer, R as typedForIn, v as visit } from './index-
|
|
1
|
+
export { B as BasicTreemapInstance, c as CreateTreemapOptions, D as DOMEventType, Y as DefaultMap, E as ExposedEventCallback, n as ExposedEventDefinition, o as ExposedEventMethods, x as GraphicConfig, w as GraphicFont, G as GraphicLayout, O as InheritedCollectionsWithParamter, L as LayoutModule, M as Module, N as NativeModule, k as Plugin, P as PluginContext, l as PluginHooks, p as PrimitiveEventMetadata, S as Series, e as TreemapInstance, T as TreemapOptions, K as applyCanvasTransform, f as c2m, J as createCanvasElement, F as createRoundBlock, H as createTitleText, d as createTreemap, m as definePlugin, g as findRelativeNode, h as findRelativeNodeById, i as flattenModule, j as getNodeDepth, y as hashCode, q as isClickEvent, r as isContextMenuEvent, t as isMouseEvent, X as isScrollWheelOrRightButtonOnMouseupAndDown, u as isWheelEvent, Q as mixin, A as noop, z as perferNumeric, I as raf, W as smoothFrame, s as sortChildrenByKey, U as stackMatrixTransform, V as stackMatrixTransformWithGraphAndLayer, R as typedForIn, v as visit } from './index-Bks7tGiV.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { B as BasicTreemapInstance, c as CreateTreemapOptions, D as DOMEventType, Y as DefaultMap, E as ExposedEventCallback, n as ExposedEventDefinition, o as ExposedEventMethods, x as GraphicConfig, w as GraphicFont, G as GraphicLayout, O as InheritedCollectionsWithParamter, L as LayoutModule, M as Module, N as NativeModule, k as Plugin, P as PluginContext, l as PluginHooks, p as PrimitiveEventMetadata, S as Series, e as TreemapInstance, T as TreemapOptions, K as applyCanvasTransform, f as c2m, J as createCanvasElement, F as createRoundBlock, H as createTitleText, d as createTreemap, m as definePlugin, g as findRelativeNode, h as findRelativeNodeById, i as flattenModule, j as getNodeDepth, y as hashCode, q as isClickEvent, r as isContextMenuEvent, t as isMouseEvent, X as isScrollWheelOrRightButtonOnMouseupAndDown, u as isWheelEvent, Q as mixin, A as noop, z as perferNumeric, I as raf, W as smoothFrame, s as sortChildrenByKey, U as stackMatrixTransform, V as stackMatrixTransformWithGraphAndLayer, R as typedForIn, v as visit } from './index-
|
|
1
|
+
export { B as BasicTreemapInstance, c as CreateTreemapOptions, D as DOMEventType, Y as DefaultMap, E as ExposedEventCallback, n as ExposedEventDefinition, o as ExposedEventMethods, x as GraphicConfig, w as GraphicFont, G as GraphicLayout, O as InheritedCollectionsWithParamter, L as LayoutModule, M as Module, N as NativeModule, k as Plugin, P as PluginContext, l as PluginHooks, p as PrimitiveEventMetadata, S as Series, e as TreemapInstance, T as TreemapOptions, K as applyCanvasTransform, f as c2m, J as createCanvasElement, F as createRoundBlock, H as createTitleText, d as createTreemap, m as definePlugin, g as findRelativeNode, h as findRelativeNodeById, i as flattenModule, j as getNodeDepth, y as hashCode, q as isClickEvent, r as isContextMenuEvent, t as isMouseEvent, X as isScrollWheelOrRightButtonOnMouseupAndDown, u as isWheelEvent, Q as mixin, A as noop, z as perferNumeric, I as raf, W as smoothFrame, s as sortChildrenByKey, U as stackMatrixTransform, V as stackMatrixTransformWithGraphAndLayer, R as typedForIn, v as visit } from './index-Bks7tGiV.js';
|
package/dist/index.js
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as logger, m as mixin, E as Event, a as assertExists, b as bindParentForModule, C as Component, D as DOMEvent } from './dom-event-
|
|
2
|
-
export { G as DefaultMap, x as applyCanvasTransform, c as c2m, w as createCanvasElement, r as createRoundBlock, t as createTitleText, h as definePlugin, f as findRelativeNode, d as findRelativeNodeById, e as flattenModule, g as getNodeDepth, o as hashCode, i as isClickEvent, j as isContextMenuEvent, k as isMouseEvent, F as isScrollWheelOrRightButtonOnMouseupAndDown, n as isWheelEvent, q as noop, p as perferNumeric, u as raf, B as smoothFrame, s as sortChildrenByKey, z as stackMatrixTransform, A as stackMatrixTransformWithGraphAndLayer, y as typedForIn, v as visit } from './dom-event-
|
|
1
|
+
import { l as logger, m as mixin, E as Event, a as assertExists, b as bindParentForModule, C as Component, D as DOMEvent } from './dom-event-DrYYfglv.mjs';
|
|
2
|
+
export { G as DefaultMap, x as applyCanvasTransform, c as c2m, w as createCanvasElement, r as createRoundBlock, t as createTitleText, h as definePlugin, f as findRelativeNode, d as findRelativeNodeById, e as flattenModule, g as getNodeDepth, o as hashCode, i as isClickEvent, j as isContextMenuEvent, k as isMouseEvent, F as isScrollWheelOrRightButtonOnMouseupAndDown, n as isWheelEvent, q as noop, p as perferNumeric, u as raf, B as smoothFrame, s as sortChildrenByKey, z as stackMatrixTransform, A as stackMatrixTransformWithGraphAndLayer, y as typedForIn, v as visit } from './dom-event-DrYYfglv.mjs';
|
|
3
3
|
|
|
4
4
|
function createTreemap(// @ts-expect-error todo fix
|
|
5
5
|
options) {
|
package/dist/plugin.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as PluginContext, D as DOMEventType, a as DOMEventMetadata, L as LayoutModule, b as DOMEvent, C as ColorMappings, B as BasicTreemapInstance } from './index-
|
|
1
|
+
import { P as PluginContext, D as DOMEventType, a as DOMEventMetadata, L as LayoutModule, b as DOMEvent, C as ColorMappings, B as BasicTreemapInstance } from './index-Bks7tGiV.js';
|
|
2
2
|
|
|
3
3
|
declare const presetHighlightPlugin: {
|
|
4
4
|
name: "treemap:preset-highlight";
|
|
@@ -8,6 +8,7 @@ declare const presetHighlightPlugin: {
|
|
|
8
8
|
onDispose(this: PluginContext): void;
|
|
9
9
|
meta: {
|
|
10
10
|
highlight: null;
|
|
11
|
+
highlightSeq: number;
|
|
11
12
|
};
|
|
12
13
|
};
|
|
13
14
|
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as PluginContext, D as DOMEventType, a as DOMEventMetadata, L as LayoutModule, b as DOMEvent, C as ColorMappings, B as BasicTreemapInstance } from './index-
|
|
1
|
+
import { P as PluginContext, D as DOMEventType, a as DOMEventMetadata, L as LayoutModule, b as DOMEvent, C as ColorMappings, B as BasicTreemapInstance } from './index-Bks7tGiV.js';
|
|
2
2
|
|
|
3
3
|
declare const presetHighlightPlugin: {
|
|
4
4
|
name: "treemap:preset-highlight";
|
|
@@ -8,6 +8,7 @@ declare const presetHighlightPlugin: {
|
|
|
8
8
|
onDispose(this: PluginContext): void;
|
|
9
9
|
meta: {
|
|
10
10
|
highlight: null;
|
|
11
|
+
highlightSeq: number;
|
|
11
12
|
};
|
|
12
13
|
};
|
|
13
14
|
|
package/dist/plugin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var domEvent = require('./dom-event-
|
|
3
|
+
var domEvent = require('./dom-event-ClwTQnot.js');
|
|
4
4
|
|
|
5
5
|
// Currently, etoile is an internal module, so we won't need too much easing functions.
|
|
6
6
|
// And the animation logic is implemented by user code.
|
|
@@ -75,11 +75,19 @@ const presetHighlightPlugin = domEvent.definePlugin({
|
|
|
75
75
|
meta.highlight?.reset();
|
|
76
76
|
meta.highlight?.update();
|
|
77
77
|
meta.highlight?.setZIndexForHighlight();
|
|
78
|
+
meta.highlightSeq = (meta.highlightSeq ?? 0) + 1;
|
|
78
79
|
return;
|
|
79
80
|
}
|
|
80
81
|
const [x, y, w, h] = module.layout;
|
|
81
82
|
const effectiveRadius = Math.min(module.config.rectRadius, w / 4, h / 4);
|
|
83
|
+
meta.highlightSeq = (meta.highlightSeq ?? 0) + 1;
|
|
84
|
+
const thisSeq = meta.highlightSeq;
|
|
82
85
|
domEvent.smoothFrame((_, cleanup)=>{
|
|
86
|
+
if (meta.highlightSeq !== thisSeq) {
|
|
87
|
+
meta.highlight?.setZIndexForHighlight();
|
|
88
|
+
cleanup();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
83
91
|
cleanup();
|
|
84
92
|
meta.highlight?.reset();
|
|
85
93
|
const mask = domEvent.createRoundBlock(x, y, w, h, {
|
|
@@ -90,7 +98,7 @@ const presetHighlightPlugin = domEvent.definePlugin({
|
|
|
90
98
|
});
|
|
91
99
|
meta.highlight?.add(mask);
|
|
92
100
|
meta.highlight?.setZIndexForHighlight('1');
|
|
93
|
-
domEvent.stackMatrixTransform(mask, matrix.e, matrix.f,
|
|
101
|
+
domEvent.stackMatrixTransform(mask, matrix.e, matrix.f, 1);
|
|
94
102
|
meta.highlight?.update();
|
|
95
103
|
}, {
|
|
96
104
|
duration: ANIMATION_DURATION
|
|
@@ -117,7 +125,8 @@ const presetHighlightPlugin = domEvent.definePlugin({
|
|
|
117
125
|
}
|
|
118
126
|
},
|
|
119
127
|
meta: {
|
|
120
|
-
highlight: null
|
|
128
|
+
highlight: null,
|
|
129
|
+
highlightSeq: 0
|
|
121
130
|
}
|
|
122
131
|
});
|
|
123
132
|
|
|
@@ -162,7 +171,7 @@ const presetDragElementPlugin = domEvent.definePlugin({
|
|
|
162
171
|
meta.dragOptions.lastY = lastY;
|
|
163
172
|
component.cleanup();
|
|
164
173
|
component.draw(false, false);
|
|
165
|
-
domEvent.stackMatrixTransformWithGraphAndLayer(component.elements, matrix.e, matrix.f,
|
|
174
|
+
domEvent.stackMatrixTransformWithGraphAndLayer(component.elements, matrix.e, matrix.f, 1);
|
|
166
175
|
component.update();
|
|
167
176
|
return true;
|
|
168
177
|
}, {
|
|
@@ -477,16 +486,19 @@ function updateViewport(pluginContext, { stateManager: state, component, matrix
|
|
|
477
486
|
highlight.highlight.reset();
|
|
478
487
|
highlight.highlight.setZIndexForHighlight();
|
|
479
488
|
}
|
|
489
|
+
if (highlight) {
|
|
490
|
+
highlight.highlightSeq = (highlight.highlightSeq ?? 0) + 1;
|
|
491
|
+
}
|
|
480
492
|
component.cleanup();
|
|
481
493
|
const { width, height } = component.render.options;
|
|
482
494
|
component.layoutNodes = component.calculateLayoutNodes(component.data, {
|
|
483
|
-
w: width,
|
|
484
|
-
h: height,
|
|
495
|
+
w: width * matrix.a,
|
|
496
|
+
h: height * matrix.d,
|
|
485
497
|
x: 0,
|
|
486
498
|
y: 0
|
|
487
|
-
},
|
|
499
|
+
}, 1);
|
|
488
500
|
component.draw(true, false);
|
|
489
|
-
domEvent.stackMatrixTransformWithGraphAndLayer(component.elements, matrix.e, matrix.f,
|
|
501
|
+
domEvent.stackMatrixTransformWithGraphAndLayer(component.elements, matrix.e, matrix.f, 1);
|
|
490
502
|
component.update();
|
|
491
503
|
if (state.canTransition('IDLE')) {
|
|
492
504
|
state.transition('IDLE');
|
|
@@ -513,8 +525,7 @@ function handleZoom(pluginContext, event, domEvent) {
|
|
|
513
525
|
const { scale, minScale, maxScale, scaleFactor } = meta.scaleOptions;
|
|
514
526
|
const oldMatrix = {
|
|
515
527
|
e: matrix.e,
|
|
516
|
-
f: matrix.f
|
|
517
|
-
a: matrix.a
|
|
528
|
+
f: matrix.f
|
|
518
529
|
};
|
|
519
530
|
const dynamicScaleFactor = Math.max(scaleFactor, scale * 0.1);
|
|
520
531
|
const delta = event.native.deltaY < 0 ? dynamicScaleFactor : -dynamicScaleFactor;
|
|
@@ -532,8 +543,7 @@ function handleZoom(pluginContext, event, domEvent) {
|
|
|
532
543
|
matrix.f = mouseY - (mouseY - matrix.f) * scaleDiff;
|
|
533
544
|
const newMatrix = {
|
|
534
545
|
e: matrix.e,
|
|
535
|
-
f: matrix.f
|
|
536
|
-
a: matrix.a
|
|
546
|
+
f: matrix.f
|
|
537
547
|
};
|
|
538
548
|
component.handleTransformCacheInvalidation(oldMatrix, newMatrix);
|
|
539
549
|
updateViewport(pluginContext, domEvent, false);
|
|
@@ -582,17 +592,19 @@ const presetZoomablePlugin = domEvent.definePlugin({
|
|
|
582
592
|
const [nodeX, nodeY, nodeW, nodeH] = targetModule.layout;
|
|
583
593
|
const { width, height } = component.render.options;
|
|
584
594
|
const currentScale = matrix.a;
|
|
595
|
+
// To prevent unlimited scale factor growth.
|
|
585
596
|
const scaleX = width * ZOOM_PADDING_RATIO / nodeW;
|
|
586
597
|
const scaleY = height * ZOOM_PADDING_RATIO / nodeH;
|
|
587
|
-
const
|
|
598
|
+
const idleScale = Math.min(scaleX, scaleY);
|
|
588
599
|
const maxAllowedScale = currentScale * MAX_SCALE_MULTIPLIER;
|
|
589
|
-
const targetScale = Math.max(currentScale, Math.min(
|
|
590
|
-
|
|
591
|
-
const
|
|
592
|
-
const
|
|
593
|
-
const
|
|
594
|
-
const
|
|
595
|
-
const
|
|
600
|
+
const targetScale = Math.max(currentScale, Math.min(idleScale, maxAllowedScale));
|
|
601
|
+
// Real world args
|
|
602
|
+
const viewportCenterX = width / 2;
|
|
603
|
+
const viewportCenterY = height / 2;
|
|
604
|
+
const originalNodeCenterX = (nodeX + nodeW / 2) / currentScale;
|
|
605
|
+
const originalNodeCenterY = (nodeY + nodeH / 2) / currentScale;
|
|
606
|
+
const targetE = viewportCenterX - originalNodeCenterX * targetScale;
|
|
607
|
+
const targetF = viewportCenterY - originalNodeCenterY * targetScale;
|
|
596
608
|
const scaleMeta = getScaleOptions.call(this);
|
|
597
609
|
if (scaleMeta) {
|
|
598
610
|
scaleMeta.scaleOptions.scale = targetScale;
|
|
@@ -615,8 +627,7 @@ const presetZoomablePlugin = domEvent.definePlugin({
|
|
|
615
627
|
};
|
|
616
628
|
const finalMatrix = {
|
|
617
629
|
e: targetE,
|
|
618
|
-
f: targetF
|
|
619
|
-
a: targetScale
|
|
630
|
+
f: targetF
|
|
620
631
|
};
|
|
621
632
|
component.handleTransformCacheInvalidation(oldMatrix, finalMatrix);
|
|
622
633
|
domEvent.smoothFrame((progress)=>{
|
|
@@ -630,15 +641,18 @@ const presetZoomablePlugin = domEvent.definePlugin({
|
|
|
630
641
|
highlight.highlight.reset();
|
|
631
642
|
highlight.highlight.setZIndexForHighlight();
|
|
632
643
|
}
|
|
644
|
+
if (highlight) {
|
|
645
|
+
highlight.highlightSeq = (highlight.highlightSeq ?? 0) + 1;
|
|
646
|
+
}
|
|
633
647
|
component.cleanup();
|
|
634
648
|
component.layoutNodes = component.calculateLayoutNodes(component.data, {
|
|
635
|
-
w: width,
|
|
636
|
-
h: height,
|
|
649
|
+
w: width * matrix.a,
|
|
650
|
+
h: height * matrix.d,
|
|
637
651
|
x: 0,
|
|
638
652
|
y: 0
|
|
639
|
-
},
|
|
653
|
+
}, 1);
|
|
640
654
|
component.draw(true, false);
|
|
641
|
-
domEvent.stackMatrixTransformWithGraphAndLayer(component.elements, matrix.e, matrix.f,
|
|
655
|
+
domEvent.stackMatrixTransformWithGraphAndLayer(component.elements, matrix.e, matrix.f, 1);
|
|
642
656
|
component.update();
|
|
643
657
|
}, {
|
|
644
658
|
duration: ANIMATION_DURATION,
|
package/dist/plugin.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as definePlugin, B as smoothFrame, r as createRoundBlock, z as stackMatrixTransform, S as Schedule, H as DEFAULT_MATRIX_LOC, F as isScrollWheelOrRightButtonOnMouseupAndDown, A as stackMatrixTransformWithGraphAndLayer, j as isContextMenuEvent, o as hashCode, P as PI_2, n as isWheelEvent, m as mixin } from './dom-event-
|
|
1
|
+
import { h as definePlugin, B as smoothFrame, r as createRoundBlock, z as stackMatrixTransform, S as Schedule, H as DEFAULT_MATRIX_LOC, F as isScrollWheelOrRightButtonOnMouseupAndDown, A as stackMatrixTransformWithGraphAndLayer, j as isContextMenuEvent, o as hashCode, P as PI_2, n as isWheelEvent, m as mixin } from './dom-event-DrYYfglv.mjs';
|
|
2
2
|
|
|
3
3
|
// Currently, etoile is an internal module, so we won't need too much easing functions.
|
|
4
4
|
// And the animation logic is implemented by user code.
|
|
@@ -73,11 +73,19 @@ const presetHighlightPlugin = definePlugin({
|
|
|
73
73
|
meta.highlight?.reset();
|
|
74
74
|
meta.highlight?.update();
|
|
75
75
|
meta.highlight?.setZIndexForHighlight();
|
|
76
|
+
meta.highlightSeq = (meta.highlightSeq ?? 0) + 1;
|
|
76
77
|
return;
|
|
77
78
|
}
|
|
78
79
|
const [x, y, w, h] = module.layout;
|
|
79
80
|
const effectiveRadius = Math.min(module.config.rectRadius, w / 4, h / 4);
|
|
81
|
+
meta.highlightSeq = (meta.highlightSeq ?? 0) + 1;
|
|
82
|
+
const thisSeq = meta.highlightSeq;
|
|
80
83
|
smoothFrame((_, cleanup)=>{
|
|
84
|
+
if (meta.highlightSeq !== thisSeq) {
|
|
85
|
+
meta.highlight?.setZIndexForHighlight();
|
|
86
|
+
cleanup();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
81
89
|
cleanup();
|
|
82
90
|
meta.highlight?.reset();
|
|
83
91
|
const mask = createRoundBlock(x, y, w, h, {
|
|
@@ -88,7 +96,7 @@ const presetHighlightPlugin = definePlugin({
|
|
|
88
96
|
});
|
|
89
97
|
meta.highlight?.add(mask);
|
|
90
98
|
meta.highlight?.setZIndexForHighlight('1');
|
|
91
|
-
stackMatrixTransform(mask, matrix.e, matrix.f,
|
|
99
|
+
stackMatrixTransform(mask, matrix.e, matrix.f, 1);
|
|
92
100
|
meta.highlight?.update();
|
|
93
101
|
}, {
|
|
94
102
|
duration: ANIMATION_DURATION
|
|
@@ -115,7 +123,8 @@ const presetHighlightPlugin = definePlugin({
|
|
|
115
123
|
}
|
|
116
124
|
},
|
|
117
125
|
meta: {
|
|
118
|
-
highlight: null
|
|
126
|
+
highlight: null,
|
|
127
|
+
highlightSeq: 0
|
|
119
128
|
}
|
|
120
129
|
});
|
|
121
130
|
|
|
@@ -160,7 +169,7 @@ const presetDragElementPlugin = definePlugin({
|
|
|
160
169
|
meta.dragOptions.lastY = lastY;
|
|
161
170
|
component.cleanup();
|
|
162
171
|
component.draw(false, false);
|
|
163
|
-
stackMatrixTransformWithGraphAndLayer(component.elements, matrix.e, matrix.f,
|
|
172
|
+
stackMatrixTransformWithGraphAndLayer(component.elements, matrix.e, matrix.f, 1);
|
|
164
173
|
component.update();
|
|
165
174
|
return true;
|
|
166
175
|
}, {
|
|
@@ -475,16 +484,19 @@ function updateViewport(pluginContext, { stateManager: state, component, matrix
|
|
|
475
484
|
highlight.highlight.reset();
|
|
476
485
|
highlight.highlight.setZIndexForHighlight();
|
|
477
486
|
}
|
|
487
|
+
if (highlight) {
|
|
488
|
+
highlight.highlightSeq = (highlight.highlightSeq ?? 0) + 1;
|
|
489
|
+
}
|
|
478
490
|
component.cleanup();
|
|
479
491
|
const { width, height } = component.render.options;
|
|
480
492
|
component.layoutNodes = component.calculateLayoutNodes(component.data, {
|
|
481
|
-
w: width,
|
|
482
|
-
h: height,
|
|
493
|
+
w: width * matrix.a,
|
|
494
|
+
h: height * matrix.d,
|
|
483
495
|
x: 0,
|
|
484
496
|
y: 0
|
|
485
|
-
},
|
|
497
|
+
}, 1);
|
|
486
498
|
component.draw(true, false);
|
|
487
|
-
stackMatrixTransformWithGraphAndLayer(component.elements, matrix.e, matrix.f,
|
|
499
|
+
stackMatrixTransformWithGraphAndLayer(component.elements, matrix.e, matrix.f, 1);
|
|
488
500
|
component.update();
|
|
489
501
|
if (state.canTransition('IDLE')) {
|
|
490
502
|
state.transition('IDLE');
|
|
@@ -511,8 +523,7 @@ function handleZoom(pluginContext, event, domEvent) {
|
|
|
511
523
|
const { scale, minScale, maxScale, scaleFactor } = meta.scaleOptions;
|
|
512
524
|
const oldMatrix = {
|
|
513
525
|
e: matrix.e,
|
|
514
|
-
f: matrix.f
|
|
515
|
-
a: matrix.a
|
|
526
|
+
f: matrix.f
|
|
516
527
|
};
|
|
517
528
|
const dynamicScaleFactor = Math.max(scaleFactor, scale * 0.1);
|
|
518
529
|
const delta = event.native.deltaY < 0 ? dynamicScaleFactor : -dynamicScaleFactor;
|
|
@@ -530,8 +541,7 @@ function handleZoom(pluginContext, event, domEvent) {
|
|
|
530
541
|
matrix.f = mouseY - (mouseY - matrix.f) * scaleDiff;
|
|
531
542
|
const newMatrix = {
|
|
532
543
|
e: matrix.e,
|
|
533
|
-
f: matrix.f
|
|
534
|
-
a: matrix.a
|
|
544
|
+
f: matrix.f
|
|
535
545
|
};
|
|
536
546
|
component.handleTransformCacheInvalidation(oldMatrix, newMatrix);
|
|
537
547
|
updateViewport(pluginContext, domEvent, false);
|
|
@@ -580,17 +590,19 @@ const presetZoomablePlugin = definePlugin({
|
|
|
580
590
|
const [nodeX, nodeY, nodeW, nodeH] = targetModule.layout;
|
|
581
591
|
const { width, height } = component.render.options;
|
|
582
592
|
const currentScale = matrix.a;
|
|
593
|
+
// To prevent unlimited scale factor growth.
|
|
583
594
|
const scaleX = width * ZOOM_PADDING_RATIO / nodeW;
|
|
584
595
|
const scaleY = height * ZOOM_PADDING_RATIO / nodeH;
|
|
585
|
-
const
|
|
596
|
+
const idleScale = Math.min(scaleX, scaleY);
|
|
586
597
|
const maxAllowedScale = currentScale * MAX_SCALE_MULTIPLIER;
|
|
587
|
-
const targetScale = Math.max(currentScale, Math.min(
|
|
588
|
-
|
|
589
|
-
const
|
|
590
|
-
const
|
|
591
|
-
const
|
|
592
|
-
const
|
|
593
|
-
const
|
|
598
|
+
const targetScale = Math.max(currentScale, Math.min(idleScale, maxAllowedScale));
|
|
599
|
+
// Real world args
|
|
600
|
+
const viewportCenterX = width / 2;
|
|
601
|
+
const viewportCenterY = height / 2;
|
|
602
|
+
const originalNodeCenterX = (nodeX + nodeW / 2) / currentScale;
|
|
603
|
+
const originalNodeCenterY = (nodeY + nodeH / 2) / currentScale;
|
|
604
|
+
const targetE = viewportCenterX - originalNodeCenterX * targetScale;
|
|
605
|
+
const targetF = viewportCenterY - originalNodeCenterY * targetScale;
|
|
594
606
|
const scaleMeta = getScaleOptions.call(this);
|
|
595
607
|
if (scaleMeta) {
|
|
596
608
|
scaleMeta.scaleOptions.scale = targetScale;
|
|
@@ -613,8 +625,7 @@ const presetZoomablePlugin = definePlugin({
|
|
|
613
625
|
};
|
|
614
626
|
const finalMatrix = {
|
|
615
627
|
e: targetE,
|
|
616
|
-
f: targetF
|
|
617
|
-
a: targetScale
|
|
628
|
+
f: targetF
|
|
618
629
|
};
|
|
619
630
|
component.handleTransformCacheInvalidation(oldMatrix, finalMatrix);
|
|
620
631
|
smoothFrame((progress)=>{
|
|
@@ -628,15 +639,18 @@ const presetZoomablePlugin = definePlugin({
|
|
|
628
639
|
highlight.highlight.reset();
|
|
629
640
|
highlight.highlight.setZIndexForHighlight();
|
|
630
641
|
}
|
|
642
|
+
if (highlight) {
|
|
643
|
+
highlight.highlightSeq = (highlight.highlightSeq ?? 0) + 1;
|
|
644
|
+
}
|
|
631
645
|
component.cleanup();
|
|
632
646
|
component.layoutNodes = component.calculateLayoutNodes(component.data, {
|
|
633
|
-
w: width,
|
|
634
|
-
h: height,
|
|
647
|
+
w: width * matrix.a,
|
|
648
|
+
h: height * matrix.d,
|
|
635
649
|
x: 0,
|
|
636
650
|
y: 0
|
|
637
|
-
},
|
|
651
|
+
}, 1);
|
|
638
652
|
component.draw(true, false);
|
|
639
|
-
stackMatrixTransformWithGraphAndLayer(component.elements, matrix.e, matrix.f,
|
|
653
|
+
stackMatrixTransformWithGraphAndLayer(component.elements, matrix.e, matrix.f, 1);
|
|
640
654
|
component.update();
|
|
641
655
|
}, {
|
|
642
656
|
duration: ANIMATION_DURATION,
|