removed inertial scrolling

Hunter
Tuesday, April 1st, 2025 at 7:33 PM

index.html+3-70

index.html
 261  			}
 262  		});
 263  		document.addEventListener('DOMContentLoaded', function() {
     -				// Variables for scroll handling
     -				let lastScrollPosition = 0;
     -				let isScrolling = false;
     -				let scrollDebounceTimer;
 264 +				// Variable to track if we're in a wheel event
 265 +				let isInWheelEvent = false;
 266  			const appContainer = document.getElementById('app-container');
 267  			let rootTask = loadTasksFromLocalStorage();
 268  			let currentTask = rootTask;

1096  			document.addEventListener('keydown', handleSave);
1097  			document.addEventListener('keydown', handleOpen);
1098  			
     -			// Add scroll handling to navigate tasks with inertia
1099 +			// Add scroll handler to block default scroll behavior
1100  			window.addEventListener('wheel', handleScroll, { passive: false });
1101  			
     -			// Scroll inertia implementation
     -			const scrollState = {
     -				momentum: 0,
     -				isAnimating: false,
     -				lastScrollTime: Date.now(),
     -				scrollAccumulator: 0,
     -				taskNavigationThreshold: 250  // Pixels needed to move one task
     -			};
     -			
1102  			function handleScroll(e) {
1103  				// Prevent the default scroll behavior
1104  				e.preventDefault();
     -				
     -				// Get scroll delta and update time
     -				const now = Date.now();
     -				const timeDelta = now - scrollState.lastScrollTime;
     -				scrollState.lastScrollTime = now;
     -				
     -				// Calculate momentum (higher for faster scrolls)
     -				const rawDelta = e.deltaY || e.detail || -e.wheelDelta;
     -				const delta = Math.sign(rawDelta) * Math.min(Math.abs(rawDelta), 100);  // Cap delta
     -				
     -				// Add to momentum based on time between scrolls (faster scrolls = more momentum)
     -				if (timeDelta < 100) {
     -					// Rapid scrolling gets more momentum
     -					scrollState.momentum += delta * (1 + (100 - timeDelta) / 100);
     -				} else {
     -					// Slower scrolling gets normal momentum
     -					scrollState.momentum += delta;
     -				}
     -				
     -				// Start animation if not already running
     -				if (!scrollState.isAnimating) {
     -					scrollState.isAnimating = true;
     -					animateMomentumScroll();
     -				}
     -			}
     -			
     -			function animateMomentumScroll() {
     -				// If momentum is close to zero, stop animation
     -				if (Math.abs(scrollState.momentum) < 0.5) {
     -					scrollState.momentum = 0;
     -					scrollState.isAnimating = false;
     -					return;
     -				}
     -				
     -				// Add momentum to accumulator
     -				scrollState.scrollAccumulator += scrollState.momentum;
     -				
     -				// Check if we've crossed the threshold to move tasks
     -				if (Math.abs(scrollState.scrollAccumulator) >= scrollState.taskNavigationThreshold) {
     -					const tasksToMove = Math.floor(Math.abs(scrollState.scrollAccumulator) / scrollState.taskNavigationThreshold);
     -					const direction = scrollState.scrollAccumulator > 0 ? 'down' : 'up';
     -					
     -					// Move the specified number of tasks
     -					for (let i = 0; i < tasksToMove; i++) {
     -						navigateTasks(direction);
     -					}
     -					
     -					// Remove the used part from accumulator
     -					scrollState.scrollAccumulator = scrollState.scrollAccumulator % scrollState.taskNavigationThreshold;
     -				}
     -				
     -				// Apply friction to slow down momentum
     -				scrollState.momentum *= 0.6;
     -				
     -				// Continue animation
     -				requestAnimationFrame(animateMomentumScroll);
1105  			}
1106  
1107  			getThemesFromCSS();