feat: add Fit to Screen zoom control utility#36
Conversation
|
Someone is attempting to deploy a commit to the itzzavdhesh's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
✅ Thanks! This PR is linked to #25 and will close it automatically when merged. |
|
Warning Review limit reached
More reviews will be available in 57 minutes and 28 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
1 issue found across 1 file
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/components/CenterCanvas.tsx">
<violation number="1" location="src/components/CenterCanvas.tsx:127">
P1: Fit-to-screen uses inconsistent zoom clamping range [0.4, 2] instead of the canvas-wide [0.25, 3], which can prevent large/small charts from actually fitting to the viewport.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| const scaleX = (containerWidth - padding) / contentWidth; | ||
| const scaleY = (containerHeight - padding) / contentHeight; | ||
| let newScale = Math.min(scaleX, scaleY); | ||
| newScale = Math.min(Math.max(0.4, newScale), 2); |
There was a problem hiding this comment.
P1: Fit-to-screen uses inconsistent zoom clamping range [0.4, 2] instead of the canvas-wide [0.25, 3], which can prevent large/small charts from actually fitting to the viewport.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/components/CenterCanvas.tsx, line 127:
<comment>Fit-to-screen uses inconsistent zoom clamping range [0.4, 2] instead of the canvas-wide [0.25, 3], which can prevent large/small charts from actually fitting to the viewport.</comment>
<file context>
@@ -99,6 +99,45 @@ export default function CenterCanvas({
+ const scaleX = (containerWidth - padding) / contentWidth;
+ const scaleY = (containerHeight - padding) / contentHeight;
+ let newScale = Math.min(scaleX, scaleY);
+ newScale = Math.min(Math.max(0.4, newScale), 2);
+ newScale = parseFloat(newScale.toFixed(2));
+
</file context>
| newScale = Math.min(Math.max(0.4, newScale), 2); | |
| newScale = Math.min(Math.max(0.25, newScale), 3); |
Related Issue
Closes #25
Summary
This PR adds a "Fit to Screen" utility button to the flowchart canvas zoom panel HUD.
Changes Made
handleFitToScreencalculation function.Testing
Screenshots
N/A
Impact
Improves canvas controls usability.
Checklist
Summary by cubic
Adds a "Fit to Screen" control to the canvas so users can quickly scale and center all blocks in view. Improves zoom usability on large flowcharts.
handleFitToScreento compute node bounds and fit content to the container with padding; clamps scale between 0.4 and 2 (2-decimal precision).Written for commit 0d950ff. Summary will update on new commits.