Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit pan in network visualization (#18) #27

Closed
wants to merge 1 commit into from

Conversation

daud99
Copy link
Contributor

@daud99 daud99 commented Oct 6, 2024

Fixing the #18

Problem: Users could pan graphs infinitely in any direction, sometimes losing the graph completely from view. We needed different handling for small graphs (that fit viewport) vs large graphs (that exceed viewport).

Solution:

  1. For small graphs that fit viewport:

    • Keep graph fully visible at all times
    • Snap back with animation if user tries to pan outside bounds
    • Center graph if no valid position is found
  2. For large graphs that exceed viewport:

    • Calculate graph's center and dimensions relative to viewport
    • Allow panning up to 10px beyond graph edges in any direction
    • Use center-based math to ensure uniform panning limits on all sides
    • Add smooth animations when bringing graph back into valid position
    • Fallback to centering if graph somehow gets completely hidden

The solution ensures users never lose track of their graphs while still maintaining fluid pan interactions. The uniform 10px edge padding gives just enough peek space without letting users pan too far.

Testing: Verified behavior with both small and large graphs at various zoom levels. Panning limits remain consistent in all directions.

Fixing the JRaviLab#18

Problem: Users could pan graphs infinitely in any direction, sometimes losing
the graph completely from view. We needed different handling for small graphs
(that fit viewport) vs large graphs (that exceed viewport).

Solution:
1. For small graphs that fit viewport:
   - Keep graph fully visible at all times
   - Snap back with animation if user tries to pan outside bounds
   - Center graph if no valid position is found

2. For large graphs that exceed viewport:
   - Calculate graph's center and dimensions relative to viewport
   - Allow panning up to 10px beyond graph edges in any direction
   - Use center-based math to ensure uniform panning limits on all sides
   - Add smooth animations when bringing graph back into valid position
   - Fallback to centering if graph somehow gets completely hidden

The solution ensures users never lose track of their graphs while still
maintaining fluid pan interactions. The uniform 10px edge padding gives just
enough peek space without letting users pan too far.

Testing: Verified behavior with both small and large graphs at various zoom
levels. Panning limits remain consistent in all directions.
Copy link

netlify bot commented Oct 6, 2024

Deploy Preview for molevolvr ready!

Name Link
🔨 Latest commit 3f0df7b
🔍 Latest deploy log https://app.netlify.com/sites/molevolvr/deploys/670224fc2808240008a7a713
😎 Deploy Preview https://deploy-preview-27--molevolvr.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@daud99 daud99 closed this Oct 6, 2024
@daud99 daud99 deleted the issue-18 branch October 6, 2024 06:01
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