function App() {}
window.onload = function(event) {
var app = new App();
window.app = app;
}
App.prototype.processingButton = function(event) {
const btn = event.currentTarget;
const carruselList = event.currentTarget.parentNode;
const track = carruselList.querySelector('.carrusel-track');
if (!track) {
console.error("El carrusel track no está presente en la página.");
return;
}
const carruselWidth = track.querySelector('.carrusel').offsetWidth;
const trackWidth = track.offsetWidth;
const listWidth = carruselList.offsetWidth;
let leftPosition;
track.style.left == "" ? leftPosition = track.style.left = 0 : leftPosition = parseFloat(track.style.left.slice(0,-2) * -1);
btn.dataset.button == "button-prev" ? this.prevAction(leftPosition, trackWidth, listWidth, carruselWidth, track) : this.nextAction(leftPosition, trackWidth, listWidth, carruselWidth, track);
}
App.prototype.prevAction = function(leftPosition, trackWidth, listWidth, carruselWidth, track) {
if (leftPosition > 0) {
track.style.left = `${-1 * (leftPosition - carruselWidth)}px`;
}
}
App.prototype.nextAction = function(leftPosition, trackWidth, listWidth, carruselWidth, track) {
if (leftPosition < (trackWidth - listWidth)) {
track.style.left = `${-1 * (leftPosition + carruselWidth)}px`
}
}
document.addEventListener("DOMContentLoaded", function() {
var modal = document.getElementById("videoModal");
var video = document.getElementById("miVideo");
var btnLeerMas = document.getElementById("btnLeerMas");
var btnCerrar = document.getElementById("cerrarModal");
// Evento para abrir el modal
btnLeerMas.addEventListener("click", function(event) {
event.preventDefault(); // Evita que el enlace recargue la página
modal.style.display = "flex";
video.play();
});
// Evento para cerrar el modal con la X
btnCerrar.addEventListener("click", function() {
modal.style.display = "none";
video.pause();
video.currentTime = 0; // Reiniciar el video al cerrar
});
// Cerrar modal al hacer clic fuera del contenido
window.addEventListener("click", function(event) {
if (event.target === modal) {
modal.style.display = "none";
video.pause();
video.currentTime = 0; // Reiniciar el video al cerrar
}
});
});
document.addEventListener("DOMContentLoaded", function() {
var video = document.getElementById("videoIntro");
var playPromise = video.play();
if (playPromise !== undefined) {
playPromise.catch(error => {
console.log("El navegador bloqueó la reproducción automática", error);
});
}
});
// Cerrar modal video intro
document.addEventListener("DOMContentLoaded", function() {
var modal = document.getElementById("videoIntroModal");
var video = document.getElementById("videoIntro");
var cerrarBtn = document.getElementById("cerrarVideoIntro");
// Reproducir el video automáticamente al cargar la página
var playPromise = video.play();
if (playPromise !== undefined) {
playPromise.catch(error => {
console.log("El navegador bloqueó la reproducción automática", error);
});
}
// Cerrar el modal al hacer clic en el botón "X"
cerrarBtn.addEventListener("click", function() {
modal.style.display = "none";
video.pause();
video.currentTime = 0; // Reiniciar el video al cerrar
});
});