|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <div class="home">
|
|
|
+ <div class="home" ref="conclusionHome$">
|
|
|
<div class="conclusion">
|
|
|
<SquareWord :word="info.textCn" />
|
|
|
<ul class="c-ul">
|
|
@@ -20,14 +20,25 @@
|
|
|
</li>
|
|
|
</ul>
|
|
|
|
|
|
+ <audio
|
|
|
+ v-show="false"
|
|
|
+ ref="conclusionAudio$"
|
|
|
+ :src="getAudioUrl(`结语.mp3`)"
|
|
|
+ controls
|
|
|
+ @timeupdate="onAudioCurTimeChange"
|
|
|
+ />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { computed } from 'vue'
|
|
|
+import { computed, watch, ref, onMounted } from 'vue'
|
|
|
import SquareWord from "@/components/SquareWord.vue";
|
|
|
import timeList from "@/data/index";
|
|
|
|
|
|
+const conclusionHome$ = ref(null)
|
|
|
+const conclusionAudio$ = ref(null)
|
|
|
+const getAudioUrl = utils.getAudioUrl
|
|
|
+
|
|
|
const props = defineProps({
|
|
|
info: Object
|
|
|
})
|
|
@@ -47,7 +58,45 @@ const fixList = computed(() => {
|
|
|
}
|
|
|
)
|
|
|
|
|
|
+const intersectionRatio = ref(0)
|
|
|
+const intersectionObserverForAudio = new IntersectionObserver((entries) => {
|
|
|
+ let entry = entries[entries.length - 1]
|
|
|
+ intersectionRatio.value = entry.intersectionRatio
|
|
|
+}, {
|
|
|
+ root: document.getElementsByClassName('long-image')[0],
|
|
|
+ threshold: [
|
|
|
+ 0.0,
|
|
|
+ 0.1,
|
|
|
+ 0.2,
|
|
|
+ 0.3,
|
|
|
+ 0.4,
|
|
|
+ 0.5,
|
|
|
+ 0.6,
|
|
|
+ 0.7,
|
|
|
+ 0.8,
|
|
|
+ 0.9,
|
|
|
+ 1.0
|
|
|
+ ]
|
|
|
+})
|
|
|
+onMounted(() => {
|
|
|
+ intersectionObserverForAudio.observe(conclusionHome$.value)
|
|
|
+})
|
|
|
|
|
|
+watch(intersectionRatio, (vNew, vOld) => {
|
|
|
+ if (vNew > 0) {
|
|
|
+ if (conclusionAudio$.value.paused && vOld <= 0 /* && !this.$isSafari */) { // safari里只能在用户操作回调函数中成功调用play。
|
|
|
+ conclusionAudio$.value.currentTime = 0
|
|
|
+ conclusionAudio$.value.play()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!conclusionAudio$.value.paused && vOld > 0 /* && !this.$isSafari */) {
|
|
|
+ conclusionAudio$.value.pause()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ setTimeout(() => {
|
|
|
+ conclusionAudio$.value.volume = vNew
|
|
|
+ }, 0)
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|