diff --git a/app.js b/app.js index dd39f39..0b138fe 100644 --- a/app.js +++ b/app.js @@ -154,6 +154,10 @@ document.querySelectorAll('.tool-btn').forEach(btn => { // Clear sum selections when switching tools if (toolId !== 'sumTool') { clearSumSelections(); + // Hide sum display when switching away from sum tool + if (sumDisplay) { + sumDisplay.style.display = 'none'; + } } else { showSumDisplay(); } @@ -1468,7 +1472,7 @@ function updateSumDisplay() { function showSumDisplay() { if (!sumDisplay) { - sumDisplay = document.getElementById('rulerDisplay'); + sumDisplay = document.getElementById('sumDisplay'); } sumDisplay.style.display = 'block'; updateSumDisplay(); @@ -1958,3 +1962,40 @@ document.addEventListener('keydown', (e) => { location.reload(); } }, true); + +// Mobile sidebar toggle functionality +document.addEventListener('DOMContentLoaded', () => { + const sidebarToggle = document.getElementById('sidebarToggle'); + const toolbar = document.querySelector('.toolbar'); + const overlay = document.getElementById('sidebarOverlay'); + + function toggleSidebar() { + toolbar.classList.toggle('open'); + overlay.classList.toggle('show'); + } + + function closeSidebar() { + toolbar.classList.remove('open'); + overlay.classList.remove('show'); + } + + // Toggle sidebar when button is clicked + sidebarToggle.addEventListener('click', toggleSidebar); + + // Close sidebar when overlay is clicked + overlay.addEventListener('click', closeSidebar); + + // Close sidebar when escape key is pressed (on mobile) + document.addEventListener('keydown', (e) => { + if (e.key === 'Escape' && window.innerWidth <= 768 && toolbar.classList.contains('open')) { + closeSidebar(); + } + }); + + // Close sidebar when window is resized to desktop size + window.addEventListener('resize', () => { + if (window.innerWidth > 768) { + closeSidebar(); + } + }); +}); diff --git a/index.html b/index.html index 734127f..0e13dc6 100644 --- a/index.html +++ b/index.html @@ -9,6 +9,8 @@