jQuery(window).on('elementor/frontend/init', function() {
function goToSlide(sliderElement) {
var hash = window.location.hash;
if (hash) {
var slideNum = parseInt(hash.replace('#slide-', ''), 10);
if (!isNaN(slideNum)) {
var slideIndex = slideNum - 1;
var swiperInstance = jQuery(sliderElement).find('.swiper')[0]?.swiper;
if (swiperInstance) {
swiperInstance.slideTo(slideIndex);
}
}
}
}
// Run when the SLIDER widget is ready (not global)
elementorFrontend.hooks.addAction('frontend/element_ready/slider.default', function($scope) {
goToSlide($scope);
// Also run on hash change
jQuery(window).on('hashchange', function() {
goToSlide($scope);
});
});
});