You may be interested in…
Your cart is currently empty!
New in store
-
9 pieces custom walnut frames with white mat.
948,21 €
-
Handmade Oak Picture Frame
16,69 € – 194,11 €Price range: 16,69 € through 194,11 €
-
Thin Dark Wood and Gold Leaf TV Frame
210,60 €
-
Natural Soap Hardwood Picture Frame, 1/2 Thin Edge
18,68 € – 203,82 €Price range: 18,68 € through 203,82 €
document.addEventListener("DOMContentLoaded", function () {
const sliders = document.querySelectorAll('.elementor-slides');
sliders.forEach(slider => {
// Pievienojam progress bar katram sliderim
const progressBar = document.createElement('div');
progressBar.classList.add('custom-progress-bar');
const progressFill = document.createElement('div');
progressFill.classList.add('custom-progress-fill');
progressBar.appendChild(progressFill);
slider.appendChild(progressBar);
// Atrodam Swiper instance
const swiperContainer = slider.querySelector('.swiper');
if (!swiperContainer) return;
// Meklējam Swiper konfigurāciju
const swiperInstance = swiperContainer.swiper;
if (!swiperInstance) {
// Ja vēl nav ielādēts, gaidām
const checkSwiper = setInterval(() => {
if (swiperContainer.swiper) {
clearInterval(checkSwiper);
setupProgress(swiperContainer.swiper, progressFill);
}
}, 100);
} else {
setupProgress(swiperInstance, progressFill);
}
});
function setupProgress(swiper, progressFill) {
const slideDuration = swiper.params.autoplay ? swiper.params.autoplay.delay : 5000;
let startTime;
function animateProgress() {
startTime = Date.now();
progressFill.style.transition = 'none';
progressFill.style.width = '0%';
requestAnimationFrame(updateProgress);
}
function updateProgress() {
const elapsed = Date.now() - startTime;
const progress = Math.min((elapsed / slideDuration) * 100, 100);
progressFill.style.width = progress + '%';
if (progress < 100) {
requestAnimationFrame(updateProgress);
}
}
// Kad mainās slaids
swiper.on('slideChangeTransitionStart', animateProgress);
animateProgress();
}
});