@antv/g6 5.0.0-beta.22 → 5.0.0-beta.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/dist/g6.min.js +2 -2
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/item/combo.js +1 -0
- package/esm/item/combo.js.map +1 -1
- package/esm/item/edge.js +2 -1
- package/esm/item/edge.js.map +1 -1
- package/esm/item/item.js +3 -4
- package/esm/item/item.js.map +1 -1
- package/esm/runtime/controller/layout.d.ts +1 -0
- package/esm/runtime/controller/layout.js +39 -4
- package/esm/runtime/controller/layout.js.map +1 -1
- package/esm/runtime/controller/viewport.js +19 -3
- package/esm/runtime/controller/viewport.js.map +1 -1
- package/esm/runtime/graph.js +28 -4
- package/esm/runtime/graph.js.map +1 -1
- package/esm/stdlib/plugin/legend/index.d.ts +1 -0
- package/esm/stdlib/plugin/legend/index.js +2 -0
- package/esm/stdlib/plugin/legend/index.js.map +1 -1
- package/esm/stdlib/theme/dark.js +22 -22
- package/esm/stdlib/theme/light.js +20 -20
- package/esm/types/view.d.ts +3 -0
- package/esm/util/animate.d.ts +1 -1
- package/esm/util/animate.js +45 -17
- package/esm/util/animate.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/item/combo.js +1 -0
- package/lib/item/combo.js.map +1 -1
- package/lib/item/edge.js +2 -1
- package/lib/item/edge.js.map +1 -1
- package/lib/item/item.js +3 -4
- package/lib/item/item.js.map +1 -1
- package/lib/runtime/controller/layout.d.ts +1 -0
- package/lib/runtime/controller/layout.js +38 -3
- package/lib/runtime/controller/layout.js.map +1 -1
- package/lib/runtime/controller/viewport.js +19 -3
- package/lib/runtime/controller/viewport.js.map +1 -1
- package/lib/runtime/graph.js +28 -4
- package/lib/runtime/graph.js.map +1 -1
- package/lib/stdlib/plugin/legend/index.d.ts +1 -0
- package/lib/stdlib/plugin/legend/index.js +2 -0
- package/lib/stdlib/plugin/legend/index.js.map +1 -1
- package/lib/stdlib/theme/dark.js +22 -22
- package/lib/stdlib/theme/light.js +20 -20
- package/lib/types/view.d.ts +3 -0
- package/lib/util/animate.d.ts +1 -1
- package/lib/util/animate.js +45 -17
- package/lib/util/animate.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -1
- package/src/item/combo.ts +1 -0
- package/src/item/edge.ts +2 -1
- package/src/item/item.ts +7 -4
- package/src/runtime/controller/layout.ts +37 -4
- package/src/runtime/controller/viewport.ts +27 -3
- package/src/runtime/graph.ts +40 -8
- package/src/stdlib/plugin/legend/index.ts +2 -0
- package/src/stdlib/theme/dark.ts +22 -22
- package/src/stdlib/theme/light.ts +20 -20
- package/src/types/view.ts +3 -0
- package/src/util/animate.ts +62 -25
package/src/util/animate.ts
CHANGED
|
@@ -6,14 +6,10 @@ import {
|
|
|
6
6
|
Path,
|
|
7
7
|
Polyline,
|
|
8
8
|
} from '@antv/g';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
IAnimate,
|
|
12
|
-
IAnimates,
|
|
13
|
-
IStateAnimate,
|
|
14
|
-
} from '../types/animate';
|
|
15
|
-
import { ItemDisplayModel, ItemShapeStyles, ShapeStyle } from '../types/item';
|
|
9
|
+
import { AnimateTiming, IAnimate, IAnimates } from '../types/animate';
|
|
10
|
+
import { ItemShapeStyles, ShapeStyle } from '../types/item';
|
|
16
11
|
import { isArrayOverlap, replaceElements } from './array';
|
|
12
|
+
import { clone, isString, uniq } from '@antv/util';
|
|
17
13
|
|
|
18
14
|
/**
|
|
19
15
|
* Initial(timing = show) shape animation start from init shape styles, and end to the shape's style config.
|
|
@@ -28,9 +24,8 @@ export const getShapeAnimateBeginStyles = (shape) => {
|
|
|
28
24
|
offsetDistance: 0,
|
|
29
25
|
};
|
|
30
26
|
if (['line', 'polyline', 'path'].includes(shapeType)) {
|
|
31
|
-
const totalLength = shape.getTotalLength();
|
|
32
27
|
return {
|
|
33
|
-
lineDash: [0,
|
|
28
|
+
lineDash: [0, '100%'],
|
|
34
29
|
...commonStyles,
|
|
35
30
|
};
|
|
36
31
|
} else if (shapeType === 'circle') {
|
|
@@ -136,13 +131,11 @@ const groupTimingAnimates = (
|
|
|
136
131
|
const isStateUpdate = segmentedTiming === 'stateUpdate';
|
|
137
132
|
animates[isStateUpdate ? 'update' : segmentedTiming].forEach((item: any) => {
|
|
138
133
|
const { order = 0, states } = item;
|
|
139
|
-
if (
|
|
140
|
-
!
|
|
141
|
-
(isStateUpdate && isArrayOverlap(states, changedStates))
|
|
142
|
-
) {
|
|
143
|
-
timingAnimateGroups[order] = timingAnimateGroups[order] || [];
|
|
144
|
-
timingAnimateGroups[order].push(item);
|
|
134
|
+
if (states?.length) {
|
|
135
|
+
if (!isArrayOverlap(states, changedStates)) return;
|
|
145
136
|
}
|
|
137
|
+
timingAnimateGroups[order] = timingAnimateGroups[order] || [];
|
|
138
|
+
timingAnimateGroups[order].push(item);
|
|
146
139
|
});
|
|
147
140
|
return timingAnimateGroups;
|
|
148
141
|
};
|
|
@@ -255,7 +248,13 @@ const runAnimateGroupOnShapes = (
|
|
|
255
248
|
}
|
|
256
249
|
return animation;
|
|
257
250
|
});
|
|
258
|
-
if (maxDurationIdx > -1)
|
|
251
|
+
if (maxDurationIdx > -1) {
|
|
252
|
+
const selfOnfinish = animations[maxDurationIdx].onfinish;
|
|
253
|
+
animations[maxDurationIdx].onfinish = () => {
|
|
254
|
+
selfOnfinish?.();
|
|
255
|
+
onfinish?.();
|
|
256
|
+
};
|
|
257
|
+
}
|
|
259
258
|
return animations;
|
|
260
259
|
};
|
|
261
260
|
|
|
@@ -276,19 +275,51 @@ const runAnimateOnShape = (
|
|
|
276
275
|
animateConfig,
|
|
277
276
|
) => {
|
|
278
277
|
let animateArr;
|
|
278
|
+
let percentLineDash = false;
|
|
279
279
|
if (!fields?.length) {
|
|
280
280
|
animateArr = getStyleDiff(shape.attributes, targetStyle);
|
|
281
281
|
} else {
|
|
282
282
|
animateArr = [{}, {}];
|
|
283
283
|
fields.forEach((key) => {
|
|
284
|
-
animateArr[0][key] =
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
284
|
+
animateArr[0][key] =
|
|
285
|
+
shape.style[key] === undefined
|
|
286
|
+
? clone(beginStyle[key])
|
|
287
|
+
: clone(shape.style[key]);
|
|
288
|
+
if (targetStyle[key] === undefined) return;
|
|
289
|
+
animateArr[1][key] = clone(targetStyle[key]);
|
|
290
|
+
if (key === 'lineDash') {
|
|
291
|
+
const beginPercents = uniq(
|
|
292
|
+
animateArr[0][key].filter(
|
|
293
|
+
(val) => isString(val) && val.includes('%'),
|
|
294
|
+
),
|
|
295
|
+
);
|
|
296
|
+
const targetPercents = uniq(
|
|
297
|
+
animateArr[1][key].filter(
|
|
298
|
+
(val) => isString(val) && val.includes('%'),
|
|
299
|
+
),
|
|
300
|
+
);
|
|
301
|
+
if (beginPercents.length || targetPercents.length) {
|
|
302
|
+
percentLineDash = clone(animateArr[0].lineDash);
|
|
303
|
+
const totalLength = (
|
|
304
|
+
shape as Line | Polyline | Path
|
|
305
|
+
).getTotalLength();
|
|
306
|
+
beginPercents.forEach((percent, i) => {
|
|
307
|
+
replaceElements(
|
|
308
|
+
animateArr[0][key],
|
|
309
|
+
percent,
|
|
310
|
+
(Number(percent.replace('%', '')) / 100) * totalLength,
|
|
311
|
+
);
|
|
312
|
+
});
|
|
313
|
+
targetPercents.forEach((percent, i) => {
|
|
314
|
+
replaceElements(
|
|
315
|
+
animateArr[1][key],
|
|
316
|
+
percent,
|
|
317
|
+
(Number(percent.replace('%', '')) / 100) * totalLength,
|
|
318
|
+
);
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
} else if (key === 'offsetDistance') {
|
|
322
|
+
animateArr[1][key] = animateArr[1][key] || 1;
|
|
292
323
|
}
|
|
293
324
|
});
|
|
294
325
|
}
|
|
@@ -300,7 +331,13 @@ const runAnimateOnShape = (
|
|
|
300
331
|
);
|
|
301
332
|
return;
|
|
302
333
|
}
|
|
303
|
-
|
|
334
|
+
const animation = shape.animate(animateArr, animateConfig);
|
|
335
|
+
if (percentLineDash) {
|
|
336
|
+
animation.onfinish = () => {
|
|
337
|
+
shape.style.lineDash = percentLineDash;
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
return animation;
|
|
304
341
|
};
|
|
305
342
|
|
|
306
343
|
/**
|