Update main.py
Browse files
main.py
CHANGED
@@ -173,6 +173,69 @@ def proxy(path):
|
|
173 |
var modal = document.getElementById('imageModal');
|
174 |
var modalImg = document.getElementById('modalImage');
|
175 |
var closeBtn = document.getElementsByClassName('close')[0];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
|
177 |
// Add click event to all images
|
178 |
document.querySelectorAll('img:not(#modalImage)').forEach(function(img) {
|
@@ -181,6 +244,10 @@ def proxy(path):
|
|
181 |
modal.style.display = 'flex';
|
182 |
modalImg.src = this.src;
|
183 |
document.body.style.overflow = 'hidden';
|
|
|
|
|
|
|
|
|
184 |
setTimeout(function() {
|
185 |
modal.classList.add('show');
|
186 |
}, 10);
|
@@ -205,6 +272,27 @@ def proxy(path):
|
|
205 |
document.addEventListener('keydown', function(e) {
|
206 |
if (e.key === 'Escape') closeModal();
|
207 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
});
|
209 |
'''
|
210 |
|
@@ -386,11 +474,38 @@ def proxy(path):
|
|
386 |
box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
|
387 |
transform: scale(0.9);
|
388 |
transition: transform 0.3s ease;
|
|
|
|
|
389 |
}
|
390 |
|
391 |
.modal.show img {
|
392 |
transform: scale(1);
|
393 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
394 |
|
395 |
.close {
|
396 |
position: absolute;
|
|
|
173 |
var modal = document.getElementById('imageModal');
|
174 |
var modalImg = document.getElementById('modalImage');
|
175 |
var closeBtn = document.getElementsByClassName('close')[0];
|
176 |
+
var scale = 1;
|
177 |
+
var isDragging = false;
|
178 |
+
var startX, startY, translateX = 0, translateY = 0;
|
179 |
+
|
180 |
+
// Add zoom controls
|
181 |
+
var zoomControls = document.createElement('div');
|
182 |
+
zoomControls.className = 'zoom-controls';
|
183 |
+
zoomControls.innerHTML = `
|
184 |
+
<button class="zoom-btn" onclick="changeZoom(0.1)">+</button>
|
185 |
+
<button class="zoom-btn" onclick="changeZoom(-0.1)">-</button>
|
186 |
+
<button class="zoom-btn" onclick="resetZoom()">Reset</button>
|
187 |
+
`;
|
188 |
+
modal.appendChild(zoomControls);
|
189 |
+
|
190 |
+
// Zoom functions
|
191 |
+
window.changeZoom = function(delta) {
|
192 |
+
scale = Math.min(Math.max(scale + delta, 0.5), 3);
|
193 |
+
applyTransform();
|
194 |
+
};
|
195 |
+
|
196 |
+
window.resetZoom = function() {
|
197 |
+
scale = 1;
|
198 |
+
translateX = 0;
|
199 |
+
translateY = 0;
|
200 |
+
applyTransform();
|
201 |
+
};
|
202 |
+
|
203 |
+
function applyTransform() {
|
204 |
+
modalImg.style.transform = `translate(${translateX}px, ${translateY}px) scale(${scale})`;
|
205 |
+
}
|
206 |
+
|
207 |
+
// Mouse wheel zoom
|
208 |
+
modal.addEventListener('wheel', function(e) {
|
209 |
+
e.preventDefault();
|
210 |
+
const delta = e.deltaY * -0.001;
|
211 |
+
scale = Math.min(Math.max(scale + delta, 0.5), 3);
|
212 |
+
applyTransform();
|
213 |
+
});
|
214 |
+
|
215 |
+
// Touch gestures for mobile
|
216 |
+
let initialDistance = 0;
|
217 |
+
modal.addEventListener('touchstart', function(e) {
|
218 |
+
if (e.touches.length === 2) {
|
219 |
+
initialDistance = Math.hypot(
|
220 |
+
e.touches[0].pageX - e.touches[1].pageX,
|
221 |
+
e.touches[0].pageY - e.touches[1].pageY
|
222 |
+
);
|
223 |
+
}
|
224 |
+
});
|
225 |
+
|
226 |
+
modal.addEventListener('touchmove', function(e) {
|
227 |
+
if (e.touches.length === 2) {
|
228 |
+
e.preventDefault();
|
229 |
+
const currentDistance = Math.hypot(
|
230 |
+
e.touches[0].pageX - e.touches[1].pageX,
|
231 |
+
e.touches[0].pageY - e.touches[1].pageY
|
232 |
+
);
|
233 |
+
const delta = (currentDistance - initialDistance) * 0.01;
|
234 |
+
scale = Math.min(Math.max(scale + delta, 0.5), 3);
|
235 |
+
initialDistance = currentDistance;
|
236 |
+
applyTransform();
|
237 |
+
}
|
238 |
+
});
|
239 |
|
240 |
// Add click event to all images
|
241 |
document.querySelectorAll('img:not(#modalImage)').forEach(function(img) {
|
|
|
244 |
modal.style.display = 'flex';
|
245 |
modalImg.src = this.src;
|
246 |
document.body.style.overflow = 'hidden';
|
247 |
+
scale = 1;
|
248 |
+
translateX = 0;
|
249 |
+
translateY = 0;
|
250 |
+
applyTransform();
|
251 |
setTimeout(function() {
|
252 |
modal.classList.add('show');
|
253 |
}, 10);
|
|
|
272 |
document.addEventListener('keydown', function(e) {
|
273 |
if (e.key === 'Escape') closeModal();
|
274 |
});
|
275 |
+
|
276 |
+
// Image dragging
|
277 |
+
modalImg.addEventListener('mousedown', function(e) {
|
278 |
+
isDragging = true;
|
279 |
+
startX = e.clientX - translateX;
|
280 |
+
startY = e.clientY - translateY;
|
281 |
+
modalImg.style.cursor = 'grabbing';
|
282 |
+
});
|
283 |
+
|
284 |
+
document.addEventListener('mousemove', function(e) {
|
285 |
+
if (isDragging) {
|
286 |
+
translateX = e.clientX - startX;
|
287 |
+
translateY = e.clientY - startY;
|
288 |
+
applyTransform();
|
289 |
+
}
|
290 |
+
});
|
291 |
+
|
292 |
+
document.addEventListener('mouseup', function() {
|
293 |
+
isDragging = false;
|
294 |
+
modalImg.style.cursor = 'grab';
|
295 |
+
});
|
296 |
});
|
297 |
'''
|
298 |
|
|
|
474 |
box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
|
475 |
transform: scale(0.9);
|
476 |
transition: transform 0.3s ease;
|
477 |
+
cursor: grab;
|
478 |
+
transform-origin: center center;
|
479 |
}
|
480 |
|
481 |
.modal.show img {
|
482 |
transform: scale(1);
|
483 |
}
|
484 |
+
|
485 |
+
.zoom-controls {
|
486 |
+
position: fixed;
|
487 |
+
bottom: 20px;
|
488 |
+
left: 50%;
|
489 |
+
transform: translateX(-50%);
|
490 |
+
display: flex;
|
491 |
+
gap: 10px;
|
492 |
+
z-index: 1001;
|
493 |
+
}
|
494 |
+
|
495 |
+
.zoom-btn {
|
496 |
+
background: rgba(255, 255, 255, 0.2);
|
497 |
+
border: 1px solid rgba(255, 255, 255, 0.4);
|
498 |
+
color: white;
|
499 |
+
padding: 8px 16px;
|
500 |
+
border-radius: 4px;
|
501 |
+
cursor: pointer;
|
502 |
+
font-size: 16px;
|
503 |
+
transition: all 0.2s ease;
|
504 |
+
}
|
505 |
+
|
506 |
+
.zoom-btn:hover {
|
507 |
+
background: rgba(255, 255, 255, 0.3);
|
508 |
+
}
|
509 |
|
510 |
.close {
|
511 |
position: absolute;
|