@antv/g 6.3.2 → 6.3.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/dist/index.esm.js +43 -79
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +43 -79
- package/dist/index.js.map +1 -1
- package/dist/index.umd.min.js +7 -7
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +2 -2
- package/types/plugins/web-animations-api/dom/AnimationTimeline.d.ts.map +1 -1
- package/types/plugins/web-animations-api/utils/bezier-easing.d.ts +1 -15
- package/types/plugins/web-animations-api/utils/bezier-easing.d.ts.map +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @antv/g
|
|
3
3
|
* @description A core module for rendering engine implements DOM API.
|
|
4
|
-
* @version 6.3.
|
|
5
|
-
* @date 10/
|
|
4
|
+
* @version 6.3.3
|
|
5
|
+
* @date 10/16/2026, 2:34:40 AM
|
|
6
6
|
* @author AntVis
|
|
7
7
|
* @docs https://g.antv.antgroup.com/
|
|
8
8
|
*/
|
|
@@ -571,55 +571,31 @@ var Animation = /*#__PURE__*/function () {
|
|
|
571
571
|
/**
|
|
572
572
|
* https://github.com/gre/bezier-easing
|
|
573
573
|
* BezierEasing - use bezier curve for transition easing function
|
|
574
|
-
* by Gaëtan Renaudeau 2014 -
|
|
574
|
+
* by Gaëtan Renaudeau 2014 - 2026 – MIT License
|
|
575
575
|
*/
|
|
576
576
|
|
|
577
|
-
//
|
|
578
|
-
|
|
579
|
-
var
|
|
580
|
-
var
|
|
581
|
-
var
|
|
582
|
-
var
|
|
583
|
-
var
|
|
584
|
-
var
|
|
585
|
-
var
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
var
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
var
|
|
592
|
-
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT;
|
|
598
|
-
};
|
|
599
|
-
|
|
600
|
-
// Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
|
|
601
|
-
var getSlope = function getSlope(aT, aA1, aA2) {
|
|
602
|
-
return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1);
|
|
603
|
-
};
|
|
604
|
-
var binarySubdivide = function binarySubdivide(aX, aA, aB, mX1, mX2) {
|
|
605
|
-
var currentX;
|
|
606
|
-
var currentT;
|
|
607
|
-
var i = 0;
|
|
608
|
-
do {
|
|
609
|
-
currentT = aA + (aB - aA) / 2.0;
|
|
610
|
-
currentX = calcBezier(currentT, mX1, mX2) - aX;
|
|
611
|
-
if (currentX > 0.0) aB = currentT;else aA = currentT;
|
|
612
|
-
} while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS);
|
|
613
|
-
return currentT;
|
|
614
|
-
};
|
|
615
|
-
var newtonRaphsonIterate = function newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {
|
|
616
|
-
for (var i = 0; i < NEWTON_ITERATIONS; ++i) {
|
|
617
|
-
var currentSlope = getSlope(aGuessT, mX1, mX2);
|
|
618
|
-
if (currentSlope === 0.0) return aGuessT;
|
|
619
|
-
var currentX = calcBezier(aGuessT, mX1, mX2) - aX;
|
|
620
|
-
aGuessT -= currentX / currentSlope;
|
|
577
|
+
// Solves x(t) = ((2a * t + 3b) * t + 3c) * t = x for t, with x in (0, 1):
|
|
578
|
+
// u = 1/t is the largest real root of x·u³ − 3c·u² − 3b·u − 2a = 0
|
|
579
|
+
var solveTForX = function solveTForX(x, a, b, c) {
|
|
580
|
+
var j = 1 / Math.max(c, Math.sqrt(x));
|
|
581
|
+
var k = x * j;
|
|
582
|
+
var l = k * j;
|
|
583
|
+
var s = c * j;
|
|
584
|
+
var q = b * l;
|
|
585
|
+
var m = s * s + q;
|
|
586
|
+
var h = -s * (s * s + 1.5 * q) - a * k * l;
|
|
587
|
+
var D = h * h - m * m * m;
|
|
588
|
+
var v;
|
|
589
|
+
if (m === 0 || D > 1e-12 * h * h) {
|
|
590
|
+
// one real root (Cardano)
|
|
591
|
+
var U = -Math.cbrt(h < 0 ? h - Math.sqrt(D) : h + Math.sqrt(D));
|
|
592
|
+
v = U + m / U || 0;
|
|
593
|
+
} else {
|
|
594
|
+
// three real roots, take the largest
|
|
595
|
+
var r = Math.sqrt(m);
|
|
596
|
+
v = 2 * r * Math.cos(Math.acos(Math.max(-1, Math.min(1, -h / (m * r)))) / 3);
|
|
621
597
|
}
|
|
622
|
-
return
|
|
598
|
+
return Math.min(1, k / (v + s));
|
|
623
599
|
};
|
|
624
600
|
var bezier = function bezier(mX1, mY1, mX2, mY2) {
|
|
625
601
|
if (!(mX1 >= 0 && mX1 <= 1 && mX2 >= 0 && mX2 <= 1)) throw new Error('bezier x values must be in [0, 1] range');
|
|
@@ -627,30 +603,19 @@ var bezier = function bezier(mX1, mY1, mX2, mY2) {
|
|
|
627
603
|
return t;
|
|
628
604
|
};
|
|
629
605
|
|
|
630
|
-
//
|
|
631
|
-
var
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
var
|
|
636
|
-
|
|
637
|
-
var currentSample = 1;
|
|
638
|
-
var lastSample = kSplineTableSize - 1;
|
|
639
|
-
for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) intervalStart += kSampleStepSize;
|
|
640
|
-
--currentSample;
|
|
641
|
-
|
|
642
|
-
// Interpolate to provide an initial guess for t
|
|
643
|
-
var dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
|
|
644
|
-
var guessForT = intervalStart + dist * kSampleStepSize;
|
|
645
|
-
var initialSlope = getSlope(guessForT, mX1, mX2);
|
|
646
|
-
if (initialSlope >= NEWTON_MIN_SLOPE) return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
|
|
647
|
-
if (initialSlope === 0.0) return guessForT;
|
|
648
|
-
return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
|
|
649
|
-
};
|
|
606
|
+
// x(t) = ((2a * t + 3b) * t + 3c) * t, y(t) = ((ay * t + by) * t + cy) * t
|
|
607
|
+
var a = (3 * mX1 - 3 * mX2 + 1) / 2;
|
|
608
|
+
var b = mX2 - 2 * mX1;
|
|
609
|
+
var c = mX1;
|
|
610
|
+
var ay = 3 * mY1 - 3 * mY2 + 1;
|
|
611
|
+
var by = 3 * (mY2 - 2 * mY1);
|
|
612
|
+
var cy = 3 * mY1;
|
|
650
613
|
return function (t) {
|
|
651
|
-
//
|
|
652
|
-
if (t
|
|
653
|
-
|
|
614
|
+
// t outside (0, 1) saturates to 0 / 1
|
|
615
|
+
if (t <= 0) return 0;
|
|
616
|
+
if (t >= 1) return 1;
|
|
617
|
+
var u = solveTForX(t, a, b, c);
|
|
618
|
+
return ((ay * u + by) * u + cy) * u;
|
|
654
619
|
};
|
|
655
620
|
};
|
|
656
621
|
|
|
@@ -1658,9 +1623,13 @@ var AnimationTimeline = /*#__PURE__*/function () {
|
|
|
1658
1623
|
if (t < Number(_this.currentTime)) t = Number(_this.currentTime);
|
|
1659
1624
|
_this.animations.sort(compareAnimations);
|
|
1660
1625
|
_this.animations = _this.tick(t, true, _this.animations)[0];
|
|
1626
|
+
// Once per frame rather than around each callback: there is one callback per started
|
|
1627
|
+
// animation, and each update goes over every animation with promises.
|
|
1628
|
+
_this.updateAnimationsPromises();
|
|
1661
1629
|
processing.forEach(function (entry) {
|
|
1662
1630
|
entry[1](t);
|
|
1663
1631
|
});
|
|
1632
|
+
_this.updateAnimationsPromises();
|
|
1664
1633
|
_this.applyPendingEffects();
|
|
1665
1634
|
};
|
|
1666
1635
|
this.document = document;
|
|
@@ -1774,17 +1743,12 @@ var AnimationTimeline = /*#__PURE__*/function () {
|
|
|
1774
1743
|
}, {
|
|
1775
1744
|
key: "requestAnimationFrame",
|
|
1776
1745
|
value: function requestAnimationFrame(f) {
|
|
1777
|
-
|
|
1778
|
-
return this.rAF(function (x) {
|
|
1779
|
-
_this3.updateAnimationsPromises();
|
|
1780
|
-
f(x);
|
|
1781
|
-
_this3.updateAnimationsPromises();
|
|
1782
|
-
});
|
|
1746
|
+
return this.rAF(f);
|
|
1783
1747
|
}
|
|
1784
1748
|
}, {
|
|
1785
1749
|
key: "tick",
|
|
1786
1750
|
value: function tick(t, isAnimationFrame, updatingAnimations) {
|
|
1787
|
-
var
|
|
1751
|
+
var _this3 = this,
|
|
1788
1752
|
_this$pendingEffects,
|
|
1789
1753
|
_this$pendingEffects2;
|
|
1790
1754
|
this.inTick = true;
|
|
@@ -1804,7 +1768,7 @@ var AnimationTimeline = /*#__PURE__*/function () {
|
|
|
1804
1768
|
newPendingEffects.push(animation.effect);
|
|
1805
1769
|
animation.markTarget();
|
|
1806
1770
|
}
|
|
1807
|
-
if (animation._needsTick)
|
|
1771
|
+
if (animation._needsTick) _this3.ticking = true;
|
|
1808
1772
|
var alive = animation._inEffect || animation._needsTick;
|
|
1809
1773
|
animation._inTimeline = alive;
|
|
1810
1774
|
if (alive) {
|