Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
map-demo
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2024-10-27 12:56:26 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
37412471cbbf360c5ca0d1fe4b4460ba3695f859
37412471
1 parent
679e230a
播放位移到指定高度
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
2 deletions
src/components/audioList.vue
src/components/audioList.vue
View file @
3741247
...
...
@@ -8,8 +8,8 @@
<van-icon @click="onClose" name="cross" color="#DD7850" size="1.25rem" />
</div>
</template>
<div class="van-hairline--top" style="padding: 1rem;">
<div v-for="(item, index) in audio_list" :key="index" class="van-hairline--bottom audio-item">
<div class="
audio-list
van-hairline--top" style="padding: 1rem;">
<div
:id="index"
v-for="(item, index) in audio_list" :key="index" class="van-hairline--bottom audio-item">
<div :class="['point', audio_index === index ? 'checked' : '']"></div>
<div :class="['text', audio_index === index ? 'checked' : '', 'van-ellipsis']" @click="toggleHandleAudio(item, index)">
{{ index + 1 }}. {{ item.title }}<span v-if="item.play" class="text-center">正在播放</span>
...
...
@@ -58,6 +58,15 @@ const onHeightChange = ({ height }) => { // 监听高度变化
if (!height) { // 关闭
onClose();
}
// 打开列表高度需要删除底部滚动空间
if (height > (0.2 * window.innerHeight)) {
$('.audio-list').css('marginBottom', 0);
}
// 添加可滚动高度
if (height === (0.2 * window.innerHeight)) {
let str = $('.audio-item').height() * audio_list.value.length;
$('.audio-list').css('marginBottom', `${str}px`);
}
}
const info_height = ref(0);
...
...
@@ -72,6 +81,9 @@ watch(
if (v) {
// 自动打开第一个
handleAudioPlay(audio_list.value[0], 0);
// 添加可滚动高度
let str = $('.audio-item').height() * audio_list.value.length;
$('.audio-list').css('marginBottom', `${str}px`);
} else {
onClose();
}
...
...
@@ -239,6 +251,20 @@ const handleAudioPlay = (item, index) => {
console.log('Operation is too fast, audio play fails')
})
}
if (index) {
// 指定滚动到播放位置
scrollToId(index);
}
}
const scrollToId = (index) => { // 滚动到指定元素
nextTick(() => {
const element = document.getElementById(index);
console.warn(element);
if (element) {
element.scrollIntoView({ behavior: "smooth", block: "start" });
}
})
}
const voicePause = () => {
...
...
Please
register
or
login
to post a comment