@antv/g6 5.0.6 → 5.0.7
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/g6.min.js +2 -2
- package/dist/lib/behaviors/drag-canvas.d.ts +4 -0
- package/dist/lib/runtime/canvas.d.ts +6 -5
- package/dist/lib/runtime/viewport.d.ts +1 -0
- package/dist/lib/types/point.d.ts +5 -0
- package/dist/lib/utils/point.d.ts +4 -4
- package/dist/lib/version.d.ts +1 -1
- package/esm/behaviors/drag-canvas.d.ts +4 -0
- package/esm/behaviors/drag-canvas.js +29 -9
- package/esm/behaviors/drag-canvas.js.map +1 -1
- package/esm/behaviors/zoom-canvas.js.map +1 -1
- package/esm/plugins/contextmenu/index.js +4 -2
- package/esm/plugins/contextmenu/index.js.map +1 -1
- package/esm/runtime/canvas.d.ts +6 -5
- package/esm/runtime/canvas.js.map +1 -1
- package/esm/runtime/viewport.d.ts +1 -0
- package/esm/runtime/viewport.js +13 -3
- package/esm/runtime/viewport.js.map +1 -1
- package/esm/types/point.d.ts +5 -0
- package/esm/utils/point.d.ts +4 -4
- package/esm/utils/point.js +2 -2
- package/esm/utils/point.js.map +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/behaviors/drag-canvas.d.ts +4 -0
- package/lib/behaviors/drag-canvas.js +28 -8
- package/lib/behaviors/drag-canvas.js.map +1 -1
- package/lib/behaviors/zoom-canvas.js.map +1 -1
- package/lib/plugins/contextmenu/index.js +4 -2
- package/lib/plugins/contextmenu/index.js.map +1 -1
- package/lib/runtime/canvas.d.ts +6 -5
- package/lib/runtime/canvas.js.map +1 -1
- package/lib/runtime/viewport.d.ts +1 -0
- package/lib/runtime/viewport.js +13 -3
- package/lib/runtime/viewport.js.map +1 -1
- package/lib/types/point.d.ts +5 -0
- package/lib/utils/point.d.ts +4 -4
- package/lib/utils/point.js +2 -2
- package/lib/utils/point.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/src/behaviors/drag-canvas.ts +32 -9
- package/src/behaviors/zoom-canvas.ts +2 -3
- package/src/plugins/contextmenu/index.ts +4 -2
- package/src/runtime/canvas.ts +6 -5
- package/src/runtime/viewport.ts +17 -4
- package/src/types/point.ts +6 -0
- package/src/utils/point.ts +6 -6
- package/src/version.ts +1 -1
package/src/runtime/viewport.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AABB } from '@antv/g';
|
|
2
2
|
import { clamp, isNumber, pick } from '@antv/util';
|
|
3
3
|
import { AnimationType, GraphEvent } from '../constants';
|
|
4
|
-
import type { FitViewOptions, ID, Point, TransformOptions, ViewportAnimationEffectTiming } from '../types';
|
|
4
|
+
import type { FitViewOptions, ID, Point, TransformOptions, Vector2, ViewportAnimationEffectTiming } from '../types';
|
|
5
5
|
import { getAnimationOptions } from '../utils/animation';
|
|
6
6
|
import { getBBoxSize, getCombinedBBox } from '../utils/bbox';
|
|
7
7
|
import { AnimateEvent, ViewportEvent, emit } from '../utils/event';
|
|
@@ -133,14 +133,24 @@ export class ViewportController {
|
|
|
133
133
|
return clamp(mode === 'relative' ? currentZoom * scale : scale, ...zoomRange!);
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
private transformResolver?: () => void;
|
|
137
|
+
|
|
136
138
|
public async transform(options: TransformOptions, animation?: ViewportAnimationEffectTiming) {
|
|
137
139
|
const { graph } = this.context;
|
|
138
|
-
const { translate, rotate, scale } = options;
|
|
140
|
+
const { translate, rotate, scale, origin } = options;
|
|
139
141
|
this.cancelAnimation();
|
|
140
142
|
|
|
141
|
-
emit(graph, new ViewportEvent(GraphEvent.BEFORE_TRANSFORM, options));
|
|
142
143
|
const _animation = this.getAnimation(animation);
|
|
143
144
|
|
|
145
|
+
// 针对缩放操作,且不涉及平移、旋转、中心点、动画时,直接调用 setZoomByViewportPoint
|
|
146
|
+
// For zoom operations, and no translation, rotation, center point, and animation involved, call setZoomByViewportPoint directly
|
|
147
|
+
if (!rotate && scale && !translate && origin && !_animation) {
|
|
148
|
+
this.camera.setZoomByViewportPoint(scale, origin as Vector2);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
emit(graph, new ViewportEvent(GraphEvent.BEFORE_TRANSFORM, options));
|
|
153
|
+
|
|
144
154
|
const landmarkOptions: Parameters<typeof this.camera.createLandmark>[1] = {};
|
|
145
155
|
if (translate) Object.assign(landmarkOptions, this.getTranslateOptions(options));
|
|
146
156
|
if (isNumber(rotate)) Object.assign(landmarkOptions, this.getRotateOptions(options));
|
|
@@ -150,11 +160,13 @@ export class ViewportController {
|
|
|
150
160
|
emit(graph, new AnimateEvent(GraphEvent.BEFORE_ANIMATE, AnimationType.TRANSFORM, null, options));
|
|
151
161
|
|
|
152
162
|
return new Promise<void>((resolve) => {
|
|
163
|
+
this.transformResolver = resolve;
|
|
153
164
|
this.camera.gotoLandmark(this.createLandmark(landmarkOptions), {
|
|
154
165
|
..._animation,
|
|
155
166
|
onfinish: () => {
|
|
156
167
|
emit(graph, new AnimateEvent(GraphEvent.AFTER_ANIMATE, AnimationType.TRANSFORM, null, options));
|
|
157
168
|
emit(graph, new ViewportEvent(GraphEvent.AFTER_TRANSFORM, options));
|
|
169
|
+
this.transformResolver = undefined;
|
|
158
170
|
resolve();
|
|
159
171
|
},
|
|
160
172
|
});
|
|
@@ -218,7 +230,7 @@ export class ViewportController {
|
|
|
218
230
|
}
|
|
219
231
|
|
|
220
232
|
private async focus(bbox: AABB, animation?: ViewportAnimationEffectTiming) {
|
|
221
|
-
const
|
|
233
|
+
const center = this.context.graph.getViewportByCanvas(bbox.center);
|
|
222
234
|
const canvasCenter = this.getCanvasCenter();
|
|
223
235
|
const delta = subtract(canvasCenter, center);
|
|
224
236
|
await this.transform({ mode: 'relative', translate: add(delta, this.paddingOffset) }, animation);
|
|
@@ -247,5 +259,6 @@ export class ViewportController {
|
|
|
247
259
|
if (this.camera.landmarks?.length) {
|
|
248
260
|
this.camera.cancelLandmarkAnimation();
|
|
249
261
|
}
|
|
262
|
+
this.transformResolver?.();
|
|
250
263
|
}
|
|
251
264
|
}
|
package/src/types/point.ts
CHANGED
package/src/utils/point.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AABB
|
|
2
|
-
import type { Point } from '../types';
|
|
1
|
+
import type { AABB } from '@antv/g';
|
|
2
|
+
import type { Point, PointObject } from '../types';
|
|
3
3
|
import { getBBoxHeight, getBBoxWidth } from './bbox';
|
|
4
4
|
import type { LineSegment } from './line';
|
|
5
5
|
import { getLinesIntersection, isLinesParallel } from './line';
|
|
@@ -12,8 +12,8 @@ import { add, distance, divide, normalize, subtract, toVector2 } from './vector'
|
|
|
12
12
|
* @param point - <zh/> 对象坐标 | <en/> object coordinates
|
|
13
13
|
* @returns <zh/> 数组坐标 | <en/> array coordinates
|
|
14
14
|
*/
|
|
15
|
-
export function parsePoint(point:
|
|
16
|
-
return [point.x, point.y];
|
|
15
|
+
export function parsePoint(point: PointObject): Point {
|
|
16
|
+
return [point.x, point.y, point.z ?? 0];
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -23,8 +23,8 @@ export function parsePoint(point: PointLike): Point {
|
|
|
23
23
|
* @param point - <zh/> 数组坐标 | <en/> array coordinates
|
|
24
24
|
* @returns <zh/> 对象坐标 | <en/> object coordinates
|
|
25
25
|
*/
|
|
26
|
-
export function toPointObject(point: Point):
|
|
27
|
-
return { x: point[0], y: point[1] };
|
|
26
|
+
export function toPointObject(point: Point): PointObject {
|
|
27
|
+
return { x: point[0], y: point[1], z: point[2] ?? 0 };
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/**
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.0.
|
|
1
|
+
export const version = '5.0.7';
|