Skip to content

improve(editor): optimize zoom wheel padding handling for zero values - #178

Merged
Aarebecca merged 2 commits into
antvis:mainfrom
taosin:improve/zoom-wheel-padding-handling
Jan 22, 2026
Merged

Aarebecca merged 2 commits into
antvis:mainfrom
taosin:improve/zoom-wheel-padding-handling

Conversation

@taosin

@taosin taosin commented Jan 22, 2026

Copy link
Copy Markdown
Contributor
  • Improve padding=0 logic: use direction-based initial values
    • Zoom in: starts from positive initial value (10)
    • Zoom out: starts from negative initial value (-10)
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @taosin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the zoom wheel functionality by optimizing how padding is calculated, especially when the current padding is zero. The update introduces a direction-based initial padding value, providing a more natural and predictable user experience during zoom operations. The changes are thoroughly validated with comprehensive new unit tests covering various scenarios and edge cases.

Highlights

  • Improved Zero Padding Logic: The zoom wheel interaction now handles zero padding values more intuitively. When zooming in from zero padding, it starts with a positive initial value (10), and when zooming out, it starts with a negative initial value (-10). This ensures a more consistent and predictable zoom behavior.
  • New Configuration Constants: Introduced ZOOM_IN_FACTOR, ZOOM_OUT_FACTOR, and INITIAL_PADDING_WHEN_ZERO constants to centralize and clarify the zoom calculation logic.
  • Expanded Test Coverage: Significantly increased unit test coverage for the ZoomWheel interaction, including new tests for various padding states (zero, non-zero, array, negative), modifier key handling, interaction activity, boundary conditions (minimum viewbox size), and edge cases like undefined padding and zero deltaY.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves the zoom-on-wheel functionality, specifically for cases where the padding is zero. The changes introduce initial padding values to make zooming from a neutral state more intuitive. The test suite has also been significantly expanded to cover various scenarios, which is a great improvement.

My review includes a few suggestions:

  • Handling wheel events where deltaY is zero to prevent unintended zooming.
  • Correcting a test case that has a misleading description.
  • A minor refactoring to simplify the zoom calculation logic and improve maintainability.
Comment thread src/editor/interactions/zoom-wheel.ts Resolved
Comment thread src/editor/interactions/zoom-wheel.ts Resolved
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.76%. Comparing base (299cfb7) to head (a8cc0df).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #178      +/-   ##
==========================================
+ Coverage   44.73%   44.76%   +0.02%     
==========================================
  Files         330      330              
  Lines       26281    26291      +10     
  Branches     2047     2051       +4     
==========================================
+ Hits        11758    11768      +10     
  Misses      14513    14513              
  Partials       10       10              
Flag Coverage Δ
infographic 44.76% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/editor/interactions/zoom-wheel.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
@Aarebecca

Copy link
Copy Markdown
Contributor

@taosin Good job, thanks for your contributing 🎉

@Aarebecca
Aarebecca merged commit 81f0f84 into antvis:main Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants