Reed Diffuser
Updating...
40) next(); if (touchEndX - touchStartX > 40) prev(); }"
x-data="(() => {
const p = product || {};
const list =
(Array.isArray(p.images) && p.images) ||
(Array.isArray(p.image_urls) && p.image_urls) ||
(Array.isArray(p.gallery) && p.gallery) ||
[];
const pickUrl = (x) => {
if (!x) return null;
if (typeof x === 'string') return x;
return x.url || x.src || x.path || x.image || x.image_url || x.thumbnail || null;
};
// ✅ FIX 1: Gabungin thumbnail sebagai array urutan pertama, baru galeri.
// Set() dipake biar kalau thumbnail sama kayak galeri, gak dobel.
const rawGallery = list.map(pickUrl);
const allUrls = [p.thumbnail, ...rawGallery].filter(Boolean);
const imgs = [...new Set(allUrls)];
return {
imgs,
idx: 0,
isHovering: false,
canHover: (typeof window !== 'undefined') && window.matchMedia && window.matchMedia('(hover: hover)').matches,
// ✅ Delay hover variant (biar gak muncul pas user scroll wheel)
variantHoverReady: false,
variantHoverT: null,
variantStripOverflow: false, // ✅ Center logic state
// ✅ FIX 2: Variabel buat deteksi gesekan jari di HP
touchStartX: 0,
touchEndX: 0,
_syncVariantStrip() {
const el = this.$refs?.variantStrip;
if (!el) return;
// overflow?
this.variantStripOverflow = (el.scrollWidth > el.clientWidth + 1);
// start position
if (this.variantStripOverflow) {
el.scrollLeft = Math.max(0, Math.floor((el.scrollWidth - el.clientWidth) / 2));
} else {
el.scrollLeft = 0;
}
},
_armVariantHover() {
if (!this.canHover) return;
clearTimeout(this.variantHoverT);
this.variantHoverT = setTimeout(() => {
this.variantHoverReady = true;
this.$nextTick(() => this._syncVariantStrip());
}, 180);
},
_disarmVariantHover() {
clearTimeout(this.variantHoverT);
this.variantHoverReady = false;
this.variantStripOverflow = false;
},
prev() { if (this.imgs.length > 1) this.idx = (this.idx - 1 + this.imgs.length) % this.imgs.length; },
next() { if (this.imgs.length > 1) this.idx = (this.idx + 1) % this.imgs.length; },
get src() { return this.imgs[this.idx] || p.thumbnail || ''; },
};
})()"
>
Sold out
NEW
BEST SELLER
🍂
Collection Coming Soon
We are currently crafting new scents for this category.