优化Animation的新增动画表现

This commit is contained in:
monitor1394
2025-03-07 22:32:27 +08:00
parent aea4aa7c8d
commit e7aae593bf
4 changed files with 32 additions and 11 deletions

View File

@@ -79,6 +79,7 @@ slug: /changelog
## master ## master
* (2025.03.06) 优化`Animation`的新增动画表现
* (2025.03.04) 修复`Treemap``label`显示异常的问题 * (2025.03.04) 修复`Treemap``label`显示异常的问题
* (2025.03.02) 增加`Tooltip``columnGapWidths`参数设置列文本间隙距离 * (2025.03.02) 增加`Tooltip``columnGapWidths`参数设置列文本间隙距离
* (2025.03.01) 优化`Comment`的组件刷新 * (2025.03.01) 优化`Comment`的组件刷新

View File

@@ -147,6 +147,7 @@ namespace XCharts.Runtime
{ {
if (!enable) return; if (!enable) return;
if (!context.start || context.end) return; if (!context.start || context.end) return;
context.init = false;
context.start = false; context.start = false;
context.end = true; context.end = true;
context.currPointIndex = context.destPointIndex; context.currPointIndex = context.destPointIndex;
@@ -168,20 +169,19 @@ namespace XCharts.Runtime
public bool Init(float curr, float dest, int totalPointIndex) public bool Init(float curr, float dest, int totalPointIndex)
{ {
if (!enable || !context.start) return false; if (!enable || !context.start) return false;
if (context.init || context.end) return false;
context.init = true;
context.totalProgress = dest - curr; context.totalProgress = dest - curr;
context.destPointIndex = totalPointIndex; context.destPointIndex = totalPointIndex;
if (reverse) if (reverse)
{ {
context.currProgress = dest; if (!context.init) context.currProgress = dest;
context.destProgress = curr; context.destProgress = curr;
} }
else else
{ {
context.currProgress = curr; if (!context.init) context.currProgress = curr;
context.destProgress = dest; context.destProgress = dest;
} }
context.init = true;
return true; return true;
} }

View File

@@ -306,7 +306,7 @@ namespace XCharts.Runtime
startIndex = anim.context.currPointIndex == paths.Count - 1 ? startIndex = anim.context.currPointIndex == paths.Count - 1 ?
paths.Count - 2 : paths.Count - 2 :
anim.context.currPointIndex; anim.context.currPointIndex;
if (startIndex < 0 || startIndex > paths.Count - 2) startIndex = 0; if (startIndex < 0 || startIndex >= paths.Count - 1) return;
} }
else else
{ {
@@ -336,9 +336,12 @@ namespace XCharts.Runtime
{ {
return; return;
} }
anim.context.currPoint = sp;
anim.context.destPoint = ep; if (anim.Init(currDetailProgress, totalDetailProgress, paths.Count - 1))
anim.Init(currDetailProgress, totalDetailProgress, paths.Count - 1); {
anim.context.currPoint = sp;
anim.context.destPoint = ep;
}
} }
public bool IsEnd() public bool IsEnd()
@@ -362,12 +365,23 @@ namespace XCharts.Runtime
return true; return true;
var animation = activedAnimation; var animation = activedAnimation;
if (animation != null && animation.context.end) if (animation != null && animation.context.end)
{
return true; return true;
}
if (IsSerieAnimation()) if (IsSerieAnimation())
{ {
if (m_FadeOut.context.start) return m_FadeOut.context.currProgress <= m_FadeOut.context.destProgress; if (m_FadeOut.context.start)
else if (m_Addition.context.start) return m_Addition.context.currProgress >= m_Addition.context.destProgress; {
else return m_FadeIn.context.currProgress >= m_FadeIn.context.destProgress; return m_FadeOut.context.currProgress <= m_FadeOut.context.destProgress;
}
else if (m_Addition.context.start)
{
return m_Addition.context.currProgress >= m_Addition.context.destProgress;
}
else
{
return m_FadeIn.context.currProgress >= m_FadeIn.context.destProgress;
}
} }
else if (IsDataAnimation()) else if (IsDataAnimation())
{ {

View File

@@ -2029,6 +2029,7 @@ namespace XCharts.Runtime
/// </summary> /// </summary>
public void AnimationFadeIn() public void AnimationFadeIn()
{ {
if (dataCount <= 0) return;
ResetInteract(); ResetInteract();
if (animation.enable) animation.FadeIn(); if (animation.enable) animation.FadeIn();
SetVerticesDirty(); SetVerticesDirty();
@@ -2039,6 +2040,7 @@ namespace XCharts.Runtime
/// </summary> /// </summary>
public void AnimationFadeOut() public void AnimationFadeOut()
{ {
if (dataCount <= 0) return;
ResetInteract(); ResetInteract();
if (animation.enable) animation.FadeOut(); if (animation.enable) animation.FadeOut();
SetVerticesDirty(); SetVerticesDirty();
@@ -2049,6 +2051,7 @@ namespace XCharts.Runtime
/// </summary> /// </summary>
public void AnimationPause() public void AnimationPause()
{ {
if (dataCount <= 0) return;
if (animation.enable) animation.Pause(); if (animation.enable) animation.Pause();
SetVerticesDirty(); SetVerticesDirty();
} }
@@ -2058,6 +2061,7 @@ namespace XCharts.Runtime
/// </summary> /// </summary>
public void AnimationResume() public void AnimationResume()
{ {
if (dataCount <= 0) return;
if (animation.enable) animation.Resume(); if (animation.enable) animation.Resume();
SetVerticesDirty(); SetVerticesDirty();
} }
@@ -2067,6 +2071,7 @@ namespace XCharts.Runtime
/// </summary> /// </summary>
public void AnimationReset() public void AnimationReset()
{ {
if (dataCount <= 0) return;
if (animation.enable) animation.Reset(); if (animation.enable) animation.Reset();
SetVerticesDirty(); SetVerticesDirty();
} }
@@ -2076,6 +2081,7 @@ namespace XCharts.Runtime
/// </summary> /// </summary>
public void AnimationRestart() public void AnimationRestart()
{ {
if (dataCount <= 0) return;
if (animation.enable) animation.Restart(); if (animation.enable) animation.Restart();
SetVerticesDirty(); SetVerticesDirty();
} }