From 6ddadaa47326855f5bb7525af6d3ebb1af4e71d3 Mon Sep 17 00:00:00 2001 From: juanatsap Date: Wed, 12 Nov 2025 14:38:43 +0000 Subject: [PATCH] fix: remove scroll compensation to prevent page jumping on zoom Removed proportional scroll adjustment that was causing page to jump down when zooming. The transform-origin: top center property keeps content anchored at top naturally without needing scroll compensation. --- static/js/main.js | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/static/js/main.js b/static/js/main.js index 18a5799..aa3e180 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -323,33 +323,17 @@ const cvFooter = document.querySelector('.cv-footer'); if (!cvContainer) return; - // Get current scale to calculate ratio - const currentTransform = cvContainer.style.transform; - const currentScaleMatch = currentTransform.match(/scale\(([\d.]+)\)/); - const oldScale = currentScaleMatch ? parseFloat(currentScaleMatch[1]) : 1.0; - // Convert percentage to scale factor (100 = 1.0, 150 = 1.5, etc.) const newScale = zoomValue / 100; requestAnimationFrame(() => { - // Store current scroll position - const oldScrollTop = window.pageYOffset || document.documentElement.scrollTop; - // Apply the new scale to both container and footer + // transform-origin: top center keeps content anchored at top cvContainer.style.transform = `scale(${newScale})`; if (cvFooter) { cvFooter.style.transform = `scale(${newScale})`; } - // Calculate proportional scroll position to maintain visual position - // If zooming from 100% to 50%, content at pixel 1000 moves to pixel 500 - // So we need to scroll to pixel 500 to see the same content - const scaleRatio = newScale / oldScale; - const newScrollTop = oldScrollTop * scaleRatio; - - // Apply new scroll position to keep same content visible - window.scrollTo(0, newScrollTop); - // Update display updateZoomDisplay(zoomValue);