|
@ -64,7 +64,39 @@ const targets = { |
|
|
table: [], |
|
|
table: [], |
|
|
sphere: [], |
|
|
sphere: [], |
|
|
}; |
|
|
}; |
|
|
|
|
|
function swapCardContents() { |
|
|
|
|
|
// 确保有足够卡片且不在抽奖状态 |
|
|
|
|
|
if (threeDCards.length < 2 || globalCardIndexes.length > 0) return; |
|
|
|
|
|
|
|
|
|
|
|
// 随机选择两张不同的卡片 |
|
|
|
|
|
let indexA = Math.floor(Math.random() * threeDCards.length); |
|
|
|
|
|
let indexB = Math.floor(Math.random() * threeDCards.length); |
|
|
|
|
|
while (indexA === indexB) { |
|
|
|
|
|
indexB = Math.floor(Math.random() * threeDCards.length); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const cardA = threeDCards[indexA].element; |
|
|
|
|
|
const cardB = threeDCards[indexB].element; |
|
|
|
|
|
|
|
|
|
|
|
// 保存原始内容(如果尚未保存) |
|
|
|
|
|
if (!cardA.dataset.originalContent) { |
|
|
|
|
|
cardA.dataset.originalContent = cardA.innerHTML; |
|
|
|
|
|
} |
|
|
|
|
|
if (!cardB.dataset.originalContent) { |
|
|
|
|
|
cardB.dataset.originalContent = cardB.innerHTML; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 交换内容并添加动画效果 |
|
|
|
|
|
[cardA.innerHTML, cardB.innerHTML] = [cardB.innerHTML, cardA.innerHTML]; |
|
|
|
|
|
cardA.classList.add('swap-animation'); |
|
|
|
|
|
cardB.classList.add('swap-animation'); |
|
|
|
|
|
|
|
|
|
|
|
// 动画结束后移除动画类 |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
cardA.classList.remove('swap-animation'); |
|
|
|
|
|
cardB.classList.remove('swap-animation'); |
|
|
|
|
|
}, 500); |
|
|
|
|
|
} |
|
|
function createElement(css = "", text = "") { |
|
|
function createElement(css = "", text = "") { |
|
|
const dom = document.createElement("div"); |
|
|
const dom = document.createElement("div"); |
|
|
dom.className = css; |
|
|
dom.className = css; |
|
@ -737,6 +769,7 @@ onMounted(async () => { |
|
|
}, 500); |
|
|
}, 500); |
|
|
|
|
|
|
|
|
window.addEventListener("resize", onWindowResize); |
|
|
window.addEventListener("resize", onWindowResize); |
|
|
|
|
|
// swapInterval.value = setInterval(swapCardContents, swapIntervalTime.value); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
onBeforeUnmount(() => { |
|
|
onBeforeUnmount(() => { |
|
@ -747,6 +780,10 @@ onBeforeUnmount(() => { |
|
|
clearTimeout(highlightTimeout); |
|
|
clearTimeout(highlightTimeout); |
|
|
highlightTimeout = null; |
|
|
highlightTimeout = null; |
|
|
} |
|
|
} |
|
|
|
|
|
// if (swapInterval.value) { |
|
|
|
|
|
// clearInterval(swapInterval.value); |
|
|
|
|
|
// swapInterval.value = null; |
|
|
|
|
|
// } |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
function render() { |
|
|
function render() { |
|
|