@@ -24,7 +24,6 @@ const slides = {
2424const prevArrow = document . getElementById ( 'prevArrow' ) ;
2525const nextArrow = document . getElementById ( 'nextArrow' ) ;
2626
27- let mouseTimer = null ;
2827let startX = 0 ;
2928let startY = 0 ;
3029let isDragging = false ; // For swipe navigation
@@ -34,13 +33,9 @@ let hasPanned = false;
3433let translateX = 0 ;
3534let translateY = 0 ;
3635let currentScale = 1 ;
37- let minX = 0 ;
38- let minY = 0 ;
39- let containerRect , imgRect ;
4036let img ;
4137
4238let baseWidth , baseHeight ; // Image dimensions before zoom
43- let baseOffsetX , baseOffsetY ; // Image position offset before zoom (due to centering)
4439
4540let scaledWidth , scaledHeight ;
4641
@@ -59,28 +54,6 @@ function updateBoundaries() {
5954}
6055
6156function limitPanning ( proposedX , proposedY ) {
62- // With transform-origin: 0 0 and transform: translate(tx, ty) scale(s)
63- //
64- // Before zoom:
65- // - Image element positioned at (baseOffsetX, baseOffsetY) in container
66- // - Image size is (baseWidth, baseHeight)
67- //
68- // After transform is applied:
69- // - First, scale happens around origin (0,0) of the element: element becomes (baseWidth*s, baseHeight*s)
70- // - Then translate by (tx, ty) moves the whole element
71- // - Final position in viewport: element's top-left is at (baseOffsetX + tx, baseOffsetY + ty)
72- // - Element's bottom-right is at (baseOffsetX + tx + scaledWidth, baseOffsetY + ty + scaledHeight)
73- //
74- // We want the image content edges to stay within the container while allowing original borders:
75- // - Left constraint: baseOffsetX + tx >= baseOffsetX => tx >= 0
76- // - Right constraint: baseOffsetX + tx + scaledWidth <= containerWidth - (containerWidth - baseOffsetX - baseWidth)
77- // baseOffsetX + tx + scaledWidth <= baseOffsetX + baseWidth
78- // tx <= baseWidth - scaledWidth
79- // - Top constraint: baseOffsetY + ty >= baseOffsetY => ty >= 0
80- // - Bottom constraint: baseOffsetY + ty + scaledHeight <= baseOffsetY + baseHeight
81- // ty <= baseHeight - scaledHeight
82-
83- // Calculate limits
8457 const maxX = 0 ;
8558 const minX = baseWidth - scaledWidth ;
8659
@@ -147,8 +120,6 @@ function handleZoom(e) {
147120 // Store the base (pre-zoom) dimensions and offset
148121 baseWidth = rect . width ;
149122 baseHeight = rect . height ;
150- baseOffsetX = rect . left ;
151- baseOffsetY = rect . top ;
152123
153124 // Calculate the scale for 1:1 pixel zoom
154125 currentScale = img . naturalWidth / rect . width ;
0 commit comments