Skip to content

Commit 535737a

Browse files
authored
fix: multi edges flight animation packet (mimi-net#369)
1 parent 8ecf85a commit 535737a

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

front/src/static/miminet_animation.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,17 @@ var PacketPlayer = (function () {
243243
this.easingImpl = (() => {
244244
return (start, end, percent) => {
245245
if (curve.ctrlpts) {
246-
let middle = (start == curve.startX || start == curve.endX) ? curve.ctrlpts[0] : curve.ctrlpts[1];
246+
// Cytoscape animates in MODEL coordinates, not rendered coordinates
247+
// Check if we're animating X or Y coordinate by comparing with curve coordinates
248+
const tolerance = 0.01;
249+
const isClose = (a, b) => Math.abs(a - b) < tolerance;
250+
251+
let isXAnimation =
252+
isClose(start, curve.startX) || isClose(end, curve.startX) ||
253+
isClose(start, curve.endX) || isClose(end, curve.endX);
254+
255+
let middle = isXAnimation ? curve.ctrlpts[0] : curve.ctrlpts[1];
256+
247257
return (1 - percent) * (1 - percent) * start + 2 * (percent) * (1 - percent) * (middle) + percent * percent * end
248258
} else {
249259
return start + (end - start) * percent;

0 commit comments

Comments
 (0)