Skip to content
document.addEventListener('DOMContentLoaded', function() {
var attempts = 0;
var maxAttempts = 20;
var checkInterval = setInterval(function() {
attempts++;
var sliderEl = document.querySelector('.product-gallery-slider.flickity-enabled');
if (sliderEl && typeof Flickity !== 'undefined') {
var flkty = Flickity.data(sliderEl);
if (flkty) {
clearInterval(checkInterval);
initVi3DragFix(flkty);
return;
}
}
if (attempts >= maxAttempts) {
clearInterval(checkInterval);
console.log('Vi3 fix: Fant ikke Flickity-instans');
}
}, 250);
});
function initVi3DragFix(flkty) {
function updateDraggable() {
if (flkty.selectedIndex === 0) {
flkty.options.draggable = false;
flkty.unbindDrag();
} else {
flkty.options.draggable = true;
flkty.bindDrag();
}
}
// Sett initial state
updateDraggable();
// Lytter til slide-endringer
flkty.on('change', function() {
updateDraggable();
});
// Sikre at touch-action er satt p� 3D-modellen ogs�
var modelDiv = document.querySelector('.VI3ModelsDiv');
if (modelDiv) {
modelDiv.style.touchAction = 'none';
var modelViewer = modelDiv.querySelector('model-viewer');
if (modelViewer) {
modelViewer.style.touchAction = 'none';
}
}
console.log('Vi3 drag fix: Aktivert');
}