Commit 53e8c574 by 李伟康

refactor(dialogue): 优化对话轴数据处理和布局计算

- 新增 axisList 数组,用于存储非空偏移量的对话数据
- 修改数据排序和遍历逻辑,提高算法效率
- 调整对话轴布局计算,避免重叠并优化位置安排
- 修复了一些与对话轴显示相关的小问题
1 parent 3fae472d
......@@ -226,6 +226,7 @@ export default {
}
this.barTop = barTop
this.containerHeight = containerHeight
let axisList = []
data?.sort((a, b) => a.offset - b.offset).forEach(e => {
const {
offset: mergedOffset,
......@@ -235,18 +236,19 @@ export default {
e.docTop = mergedOffset / totalDuration * containerHeight
e.text_id = `text_${mergedOffset}`
e.mergedOffset = mergedOffset
if (mergedOffset != null) axisList.push(e)
})
data?.map((e, index) => {
axisList.map((e, index) => {
// 检查并调整 top 值,避免重叠
for (let i = 0; i < index; i++) {
if (e.top < data[i].top + margin &&
e.top + margin > data[i].top) {
if (e.top < axisList[i].top + margin &&
e.top + margin > axisList[i].top) {
// 如果重叠,将当前元素的 top 设置为前一个元素的底部加上 margin
e.top = data[i].top + margin;
e.top = axisList[i].top + margin;
}
}
})
this.axisList = data
this.axisList = axisList
})
},
onTimeUpdate () {
......@@ -506,7 +508,7 @@ export default {
}
.up {
height: auto;
opacity:1;
opacity: 1;
.arrow {
transform: rotate(180deg);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!