词云修改
This commit is contained in:
parent
9667e9cef6
commit
1f2ccfc4ff
|
|
@ -43,6 +43,8 @@ const scanAngle = ref(0)
|
||||||
const scanTimer = ref(null)
|
const scanTimer = ref(null)
|
||||||
const containerWidth = 350
|
const containerWidth = 350
|
||||||
const containerHeight = 276
|
const containerHeight = 276
|
||||||
|
// 添加状态变量跟踪是否已完成第一个周期
|
||||||
|
const hasCompletedFirstCycle = ref(false)
|
||||||
|
|
||||||
const words = ref(props.wordsCloudList)
|
const words = ref(props.wordsCloudList)
|
||||||
|
|
||||||
|
|
@ -80,17 +82,31 @@ const startScan = () => {
|
||||||
const progress = (elapsedTime / duration) % 1
|
const progress = (elapsedTime / duration) % 1
|
||||||
const newScanAngle = progress * 360
|
const newScanAngle = progress * 360
|
||||||
|
|
||||||
|
// 只在第一个周期结束时执行一次重置
|
||||||
if (newScanAngle < scanAngle.value) {
|
if (newScanAngle < scanAngle.value) {
|
||||||
words.value.forEach((w) => (w.visible = false))
|
if (!hasCompletedFirstCycle.value) {
|
||||||
startTime = timestamp
|
// 第一个周期结束,标记为已完成
|
||||||
|
hasCompletedFirstCycle.value = true
|
||||||
|
} else {
|
||||||
|
// 后续周期不再重置词语可见性
|
||||||
|
// 但仍需更新startTime以保持动画流畅
|
||||||
|
startTime = timestamp
|
||||||
|
}
|
||||||
}
|
}
|
||||||
scanAngle.value = newScanAngle
|
scanAngle.value = newScanAngle
|
||||||
|
|
||||||
words.value.forEach((word) => {
|
// 始终显示所有词语(第一个周期后)或根据扫描角度显示(第一个周期)
|
||||||
if (!word.visible && scanAngle.value >= word.angle) {
|
if (hasCompletedFirstCycle.value) {
|
||||||
|
words.value.forEach((word) => {
|
||||||
word.visible = true
|
word.visible = true
|
||||||
}
|
})
|
||||||
})
|
} else {
|
||||||
|
words.value.forEach((word) => {
|
||||||
|
if (!word.visible && scanAngle.value >= word.angle) {
|
||||||
|
word.visible = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
scanTimer.value = requestAnimationFrame(animate)
|
scanTimer.value = requestAnimationFrame(animate)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ const scanAngle = ref(0)
|
||||||
const scanTimer = ref(null)
|
const scanTimer = ref(null)
|
||||||
const containerWidth = 370
|
const containerWidth = 370
|
||||||
const containerHeight = 257
|
const containerHeight = 257
|
||||||
|
const hasCompletedFirstCycle = ref(false) // 添加新状态跟踪是否完成第一个周期
|
||||||
|
|
||||||
const words = ref(props.wordsCloudList)
|
const words = ref(props.wordsCloudList)
|
||||||
|
|
||||||
|
|
@ -82,16 +83,28 @@ const startScan = () => {
|
||||||
const newScanAngle = progress * 360
|
const newScanAngle = progress * 360
|
||||||
|
|
||||||
if (newScanAngle < scanAngle.value) {
|
if (newScanAngle < scanAngle.value) {
|
||||||
words.value.forEach((w) => (w.visible = false))
|
// 只在第一个周期结束时执行一次隐藏操作
|
||||||
|
if (!hasCompletedFirstCycle.value) {
|
||||||
|
words.value.forEach((w) => (w.visible = false))
|
||||||
|
hasCompletedFirstCycle.value = true // 标记已完成第一个周期
|
||||||
|
}
|
||||||
startTime = timestamp
|
startTime = timestamp
|
||||||
}
|
}
|
||||||
scanAngle.value = newScanAngle
|
scanAngle.value = newScanAngle
|
||||||
|
|
||||||
words.value.forEach((word) => {
|
// 只有在第一个周期内才根据角度显示词语
|
||||||
if (!word.visible && scanAngle.value >= word.angle) {
|
if (!hasCompletedFirstCycle.value) {
|
||||||
|
words.value.forEach((word) => {
|
||||||
|
if (!word.visible && scanAngle.value >= word.angle) {
|
||||||
|
word.visible = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
// 第一个周期结束后,所有词语保持可见
|
||||||
|
words.value.forEach((word) => {
|
||||||
word.visible = true
|
word.visible = true
|
||||||
}
|
})
|
||||||
})
|
}
|
||||||
|
|
||||||
scanTimer.value = requestAnimationFrame(animate)
|
scanTimer.value = requestAnimationFrame(animate)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ const scanAngle = ref(0)
|
||||||
const scanTimer = ref(null)
|
const scanTimer = ref(null)
|
||||||
const containerWidth = 370
|
const containerWidth = 370
|
||||||
const containerHeight = 276
|
const containerHeight = 276
|
||||||
|
const hasCompletedFirstCycle = ref(false) // 添加新状态跟踪是否完成第一个周期
|
||||||
|
|
||||||
const words = ref(props.wordsCloudList)
|
const words = ref(props.wordsCloudList)
|
||||||
|
|
||||||
|
|
@ -82,16 +83,28 @@ const startScan = () => {
|
||||||
const newScanAngle = progress * 360
|
const newScanAngle = progress * 360
|
||||||
|
|
||||||
if (newScanAngle < scanAngle.value) {
|
if (newScanAngle < scanAngle.value) {
|
||||||
words.value.forEach((w) => (w.visible = false))
|
// 只在第一个周期结束时执行一次隐藏操作
|
||||||
|
if (!hasCompletedFirstCycle.value) {
|
||||||
|
words.value.forEach((w) => (w.visible = false))
|
||||||
|
hasCompletedFirstCycle.value = true // 标记已完成第一个周期
|
||||||
|
}
|
||||||
startTime = timestamp
|
startTime = timestamp
|
||||||
}
|
}
|
||||||
scanAngle.value = newScanAngle
|
scanAngle.value = newScanAngle
|
||||||
|
|
||||||
words.value.forEach((word) => {
|
// 只有在第一个周期内才根据角度显示词语
|
||||||
if (!word.visible && scanAngle.value >= word.angle) {
|
if (!hasCompletedFirstCycle.value) {
|
||||||
|
words.value.forEach((word) => {
|
||||||
|
if (!word.visible && scanAngle.value >= word.angle) {
|
||||||
|
word.visible = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
// 第一个周期结束后,所有词语保持可见
|
||||||
|
words.value.forEach((word) => {
|
||||||
word.visible = true
|
word.visible = true
|
||||||
}
|
})
|
||||||
})
|
}
|
||||||
|
|
||||||
scanTimer.value = requestAnimationFrame(animate)
|
scanTimer.value = requestAnimationFrame(animate)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ const scanAngle = ref(0)
|
||||||
const scanTimer = ref(null)
|
const scanTimer = ref(null)
|
||||||
const containerWidth = 370
|
const containerWidth = 370
|
||||||
const containerHeight = 276
|
const containerHeight = 276
|
||||||
|
const hasCompletedFirstCycle = ref(false) // 添加新状态跟踪是否完成第一个周期
|
||||||
|
|
||||||
const words = ref(props.wordsCloudList)
|
const words = ref(props.wordsCloudList)
|
||||||
|
|
||||||
|
|
@ -82,16 +83,28 @@ const startScan = () => {
|
||||||
const newScanAngle = progress * 360
|
const newScanAngle = progress * 360
|
||||||
|
|
||||||
if (newScanAngle < scanAngle.value) {
|
if (newScanAngle < scanAngle.value) {
|
||||||
words.value.forEach((w) => (w.visible = false))
|
// 只在第一个周期结束时执行一次隐藏操作
|
||||||
|
if (!hasCompletedFirstCycle.value) {
|
||||||
|
words.value.forEach((w) => (w.visible = false))
|
||||||
|
hasCompletedFirstCycle.value = true // 标记已完成第一个周期
|
||||||
|
}
|
||||||
startTime = timestamp
|
startTime = timestamp
|
||||||
}
|
}
|
||||||
scanAngle.value = newScanAngle
|
scanAngle.value = newScanAngle
|
||||||
|
|
||||||
words.value.forEach((word) => {
|
// 只有在第一个周期内才根据角度显示词语
|
||||||
if (!word.visible && scanAngle.value >= word.angle) {
|
if (!hasCompletedFirstCycle.value) {
|
||||||
|
words.value.forEach((word) => {
|
||||||
|
if (!word.visible && scanAngle.value >= word.angle) {
|
||||||
|
word.visible = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
// 第一个周期结束后,所有词语保持可见
|
||||||
|
words.value.forEach((word) => {
|
||||||
word.visible = true
|
word.visible = true
|
||||||
}
|
})
|
||||||
})
|
}
|
||||||
|
|
||||||
scanTimer.value = requestAnimationFrame(animate)
|
scanTimer.value = requestAnimationFrame(animate)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user