hookehuyr

自动播放音频的高度优化

......@@ -64,7 +64,7 @@ const onHeightChange = ({ height }) => { // 监听高度变化
}
// 添加可滚动高度
if (height === (0.2 * window.innerHeight)) {
let str = $('.audio-item').height() * audio_list.value.length;
let str = $('.audio-item').outerHeight() * (audio_list.value.length + 1.25);
$('.audio-list').css('marginBottom', `${str}px`);
}
}
......@@ -81,9 +81,11 @@ watch(
if (v) {
// 自动打开第一个
handleAudioPlay(audio_list.value[0], 0);
// 添加可滚动高度
let str = $('.audio-item').height() * audio_list.value.length;
$('.audio-list').css('marginBottom', `${str}px`);
nextTick(() => {
// 添加可滚动高度
let str = $('.audio-item').outerHeight() * (audio_list.value.length + 1.25);
$('.audio-list').css('marginBottom', `${str}px`);
})
} else {
onClose();
}
......@@ -251,10 +253,8 @@ const handleAudioPlay = (item, index) => {
console.log('Operation is too fast, audio play fails')
})
}
if (index) {
// 指定滚动到播放位置
scrollToId(index);
}
// 指定滚动到播放位置
scrollToId(index);
}
const scrollToId = (index) => { // 滚动到指定元素
......