Spaces:
Sleeping
Sleeping
Download src/static/js/toggle_btn.js from castecabas/Recicler: direct link, hf CLI and curl.
- Browser
- Download file 1.56 kB
-
https://huggingface.co/spaces/castecabas/Recicler/resolve/main/src/static/js/toggle_btn.js
- Command line
-
hf download hf://spaces/castecabas/Recicler/src/static/js/toggle_btn.js
-
curl -L -o toggle_btn.js https://huggingface.co/spaces/castecabas/Recicler/resolve/main/src/static/js/toggle_btn.js
1.56 kB
| document.addEventListener("DOMContentLoaded", () => { | |
| // Precargar todas las imágenes | |
| const preloadImages = () => { | |
| const images = document.querySelectorAll('.miniature'); | |
| images.forEach(img => { | |
| // Establecer un evento para cuando la imagen cargue | |
| img.onload = function() { | |
| // Cuando la imagen cargue, actualiza la altura del contenedor | |
| const toggleContent = img.closest('.toggle-content'); | |
| if (toggleContent && toggleContent.classList.contains('show')) { | |
| toggleContent.style.maxHeight = toggleContent.scrollHeight + "px"; | |
| } | |
| }; | |
| // Si la imagen ya está cargada (desde caché) | |
| if (img.complete) { | |
| img.onload(); | |
| } | |
| }); | |
| }; | |
| // Llamar a precargar imágenes | |
| preloadImages(); | |
| // Manejar los botones de toggle | |
| document.querySelectorAll(".toggle-button").forEach(button => { | |
| button.addEventListener("click", function () { | |
| const content = this.nextElementSibling; | |
| if (content.classList.contains("show")) { | |
| content.style.maxHeight = null; | |
| content.classList.remove("show"); | |
| } else { | |
| setTimeout(() => { | |
| content.style.maxHeight = content.scrollHeight + "px"; | |
| }, 10); | |
| content.classList.add("show"); | |
| } | |
| }); | |
| }); | |
| }); |