Skip to content

fix(animation): carousel fails to scroll to bottom with fractional row heights - #5333

Open
dajiaohuang wants to merge 1 commit into
VisActor:developfrom
dajiaohuang:fix/carousel-animation-fractional-row-height
Open

dajiaohuang wants to merge 1 commit into
VisActor:developfrom
dajiaohuang:fix/carousel-animation-fractional-row-height

Conversation

@dajiaohuang

Copy link
Copy Markdown
Contributor

🤔 This is a ...

  • Bug fix
  • New feature
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Refactoring
  • Update dependency
  • Code style optimization
  • Test Case
  • Branch merge
  • Site / documentation update
  • Demo update
  • Workflow
  • Chore
  • Other (about what?)

🔗 Related issue link

fix #4812

💡 Background and solution

When using TableCarouselAnimationPlugin with defaultRowHeight set to a decimal value (e.g., 34.666666666666664), the animation would fail to scroll to the bottom of the table and loop incorrectly.

Root cause:

  1. scrollToRow only scheduled post-animation scroll position correction when the target row was an integer. For fractional scroll targets (used during animation for smooth sub-row positioning), the correction timer was skipped, leaving the final scrollTop slightly off due to cumulative Math.floor rounding during animation frames.
  2. The carousel plugin relied only on screenTopRow !== this.row to detect end-of-scroll, which could fail with fractional row positions when floating-point accumulation error caused a mismatch even though scrolling completed.
  3. Animateaaa.onUpdate used Math.floor for intermediate scroll offsets, causing a downward pixel drift over the animation duration.

Fix:

  1. Always schedule post-animation scroll correction after animation completes (remove integer-only condition).
  2. Add post-animation correction to scrollToCol for consistency with scrollToRow.
  3. Change Math.floor to Math.round in Animateaaa.onUpdate to minimize cumulative drift during animation.
  4. Add explicit boundary check (this.row >= this.table.rowCount - 1 and col equivalent) in the carousel plugin to reliably reset to start when reaching end regardless of fractional drift.

📝 Changelog

Language Changelog
🇺🇸 English Fix carousel animation plugin not scrolling to bottom when defaultRowHeight is a non-integer value
🇨🇳 Chinese 修复动画插件在行高为小数时无法滚动到最底部的问题

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

…ctional row/col heights

- Run post-animation scroll correction for both integer and fractional scroll targets
- Add post-animation correction for scrollToCol (consistent with scrollToRow)
- Use Math.round instead of Math.floor in animation onUpdate to reduce pixel drift
- Add explicit boundary check in carousel plugin to reliably reset at end of scroll range
- Fixes TableCarouselAnimationPlugin failing to reach bottom when defaultRowHeight is a decimal value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 动画插件,行高为小数时,滚不到最底部

1 participant