@@ -2694,38 +2694,26 @@ <h3>Proofs</h3>
2694
2694
} ) ;
2695
2695
2696
2696
// Sidebar swipe gesture
2697
- let startX = 0 ; // Starting X coordinate
2698
- let currentX = 0 ; // Current X coordinate during touchmove
2699
- const swipeThreshold = 50 ; // Minimum distance to consider a swipe
2700
-
2701
- // Add touch event listeners to the sidebar and main container
2702
- const mainContainer = document . querySelector ( '.main-container' ) ;
2703
-
2704
- mainContainer . addEventListener ( 'touchstart' , ( e ) => {
2705
- startX = e . touches [ 0 ] . clientX ; // Record the starting touch point
2706
- } ) ;
2707
-
2708
- mainContainer . addEventListener ( 'touchmove' , ( e ) => {
2709
- currentX = e . touches [ 0 ] . clientX ; // Update current touch point
2710
- } ) ;
2711
-
2712
- mainContainer . addEventListener ( 'touchend' , ( ) => {
2713
- const swipeDistance = currentX - startX ;
2714
-
2715
- if ( swipeDistance > swipeThreshold ) {
2716
- // Swipe Right - Show Sidebar
2697
+ let startX = 0 ;
2698
+ let endX = 0 ;
2699
+
2700
+ document . addEventListener ( 'touchstart' , ( e ) => {
2701
+ startX = e . changedTouches [ 0 ] . clientX ;
2702
+ } , false ) ;
2703
+
2704
+ document . addEventListener ( 'touchmove' , ( e ) => {
2705
+ endX = e . changedTouches [ 0 ] . clientX ;
2706
+ } , false ) ;
2707
+
2708
+ document . addEventListener ( 'touchend' , ( ) => {
2709
+ const difference = endX - startX ;
2710
+ // Set a minimum distance to qualify as a swipe (e.g. 50px)
2711
+ if ( difference > 50 ) {
2712
+ // Swiped from left to right => open sidebar
2717
2713
sidebar . classList . add ( 'expanded' ) ;
2718
- sidebar . classList . remove ( 'collapsed' ) ;
2719
- sidebarToggle . classList . add ( 'active' ) ;
2720
- } else if ( swipeDistance < - swipeThreshold ) {
2721
- // Swipe Left - Hide Sidebar
2714
+ } else if ( difference < - 50 ) {
2715
+ // Swiped from right to left => close sidebar
2722
2716
sidebar . classList . remove ( 'expanded' ) ;
2723
- sidebar . classList . add ( 'collapsed' ) ;
2724
- sidebarToggle . classList . remove ( 'active' ) ;
2725
2717
}
2726
-
2727
- // Reset touch positions
2728
- startX = 0 ;
2729
- currentX = 0 ;
2730
- } ) ;
2718
+ } , false ) ;
2731
2719
</ script >
0 commit comments