JRaviLab / molevolvr2.0

WIP new molevolvr app
https://molevolvr.netlify.app/
1 stars 10 forks source link

Limit pan in network visualization (#18) #27

Closed daud99 closed 1 month ago

daud99 commented 1 month ago

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.

netlify[bot] commented 1 month ago

Deploy Preview for molevolvr ready!

Name Link
Latest commit 3f0df7b43f4644fa559e6b4793a79069bd050c4d
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.