Skip to content

Add smooth scrolling functionality to worksheet#7

Merged
hackerwins merged 1 commit into
mainfrom
smooth-scroll
Aug 6, 2024
Merged

Add smooth scrolling functionality to worksheet#7
hackerwins merged 1 commit into
mainfrom
smooth-scroll

Conversation

@hackerwins

@hackerwins hackerwins commented Aug 5, 2024

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it?

Add smooth scrolling functionality to worksheet

screen-capture.1.webm

Any background context you want to provide?

What are the relevant tickets?

Fixes #

Checklist

  • Added relevant tests or not required
  • Didn't break anything

Summary by CodeRabbit

  • New Features

    • Enhanced scrolling functionality during cell selection in the worksheet.
    • Implemented smoother and more controlled scrolling behavior based on mouse position.
  • Improvements

    • Scrolling now remains active even when the mouse moves outside the scroll container, improving usability.
    • Updated cleanup logic to ensure no lingering intervals after user interaction.

@coderabbitai

coderabbitai Bot commented Aug 5, 2024

Copy link
Copy Markdown

Walkthrough

The updates to the Worksheet class significantly enhance mouse interactions for scrolling during cell selection. New constants control scrolling speed and intervals, while the mouse movement logic has been adjusted to initiate scrolling when the pointer approaches the window edges. Event listeners have been improved for better usability, ensuring a fluid selection experience. Additionally, cleanup processes have been refined to prevent lingering intervals after interactions.

Changes

Files Change Summary
src/spreadsheet/worksheet.ts Enhanced mouse interaction for scrolling, introduced constants for control, updated event listeners, and refined cleanup logic.

Poem

In the land of cells so bright,
A rabbit hops with pure delight,
With scrolling smooth and swift like air,
No boundaries shall cause despair!
A dance of clicks, a joyful spree,
Interactive fun, for you and me! 🐰✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@hackerwins
hackerwins marked this pull request as ready for review August 5, 2024 13:51

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 810a3dc and 3f60945.

Files selected for processing (1)
  • src/spreadsheet/worksheet.ts (2 hunks)
Additional comments not posted (4)
src/spreadsheet/worksheet.ts (4)

20-21: LGTM! Constants for scroll interval and speed improve maintainability.

The addition of ScrollIntervalMS and ScrollSpeedMS constants enhances the readability and maintainability of the code by avoiding magic numbers.


196-225: LGTM! Smooth scrolling logic is well-implemented.

The onMove method is updated to handle smooth scrolling when the mouse moves outside the window boundaries. The use of setInterval for smooth scrolling is appropriate and the scroll offset calculation is correct.


228-233: LGTM! Scroll interval cleanup is handled correctly.

The onUp method ensures that the scroll interval is cleared correctly and the event listeners are removed to prevent memory leaks.


236-237: LGTM! Event listeners added to document improve usability.

Adding mousemove and mouseup event listeners to the document ensures that the scrolling functionality remains active even if the mouse moves outside the bounds of the scroll container, enhancing the user experience.

@hackerwins
hackerwins marked this pull request as draft August 5, 2024 13:54

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3f60945 and d3a500a.

Files selected for processing (1)
  • src/spreadsheet/worksheet.ts (2 hunks)
Additional comments not posted (3)
src/spreadsheet/worksheet.ts (3)

20-21: LGTM! Constants for smooth scrolling are defined correctly.

The constants ScrollIntervalMS and ScrollSpeedMS are defined with values that seem reasonable for smooth scrolling.


196-198: LGTM! Smooth scrolling logic is implemented correctly.

The logic for handling smooth scrolling when the mouse moves to the edges of the window is sound.


239-240: LGTM! Event listeners are correctly added to the document.

The changes ensure that the scrolling functionality remains active even if the mouse moves outside the bounds of the scroll container, improving user experience.

Comment thread src/spreadsheet/worksheet.ts Outdated
Comment thread src/spreadsheet/worksheet.ts
Comment thread src/spreadsheet/worksheet.ts
@hackerwins
hackerwins marked this pull request as ready for review August 6, 2024 12:55

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d3a500a and e0be479.

Files selected for processing (1)
  • src/spreadsheet/worksheet.ts (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/spreadsheet/worksheet.ts

@hackerwins
hackerwins merged commit b46a3e6 into main Aug 6, 2024
@hackerwins
hackerwins deleted the smooth-scroll branch August 6, 2024 12:58
hackerwins added a commit that referenced this pull request Apr 18, 2026
- Add Multer fileSize/fileFilter to FileInterceptor (#3)
- Move external input guard before all keyboard shortcuts (#5)
- Re-anchor image to cell under top-left after drag move (#6)
- Use drop coordinates for image insertion position (#7)
- Move file input outside desktop branch for mobile (#8)
- Gate context menu delete on onDeleteImage handler (#9)
hackerwins added a commit that referenced this pull request Apr 18, 2026
- Use pointerup coordinates for final draft commit (#6)
- Handle pointercancel to clear stuck drag state (#7)
- Preserve aspect ratio when clamping corner resizes (#4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant