Skip to content

Commit

Permalink
feat: Improve node sizing responsiveness for mobile devices
Browse files Browse the repository at this point in the history
  • Loading branch information
sanity committed Dec 3, 2024
1 parent d306a8d commit 47a351c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions hugo-site/layouts/shortcodes/summary-delta-sync/propagation.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,15 @@
60
);

// Increase base node size for mobile
const baseSizeFactor = containerWidth < 768 ? 0.035 : 0.02;
// Calculate node size based on viewport width
const viewportScale = Math.min(containerWidth / 1000, 1); // Scale factor based on viewport width
const baseSizeFactor = containerWidth < 768 ? 0.06 : 0.025;
const minSize = containerWidth < 768 ? 30 : 20;
const maxSize = containerWidth < 768 ? 60 : 35;

const optimalNodeSize = Math.min(
Math.max(15, Math.floor(Math.sqrt(availableArea) * baseSizeFactor)),
containerWidth < 768 ? 40 : 30
Math.max(minSize, Math.floor(Math.sqrt(availableArea) * baseSizeFactor * viewportScale)),
maxSize
);

return {
Expand Down

0 comments on commit 47a351c

Please sign in to comment.