优化评论打开动画
This commit is contained in:
parent
de47f9a8e5
commit
d4c56ed6e9
@ -7,6 +7,7 @@
|
|||||||
:show-heng-gang="false"
|
:show-heng-gang="false"
|
||||||
maskMode="light"
|
maskMode="light"
|
||||||
:height="height"
|
:height="height"
|
||||||
|
tag="comment"
|
||||||
mode="white">
|
mode="white">
|
||||||
<template v-slot:header>
|
<template v-slot:header>
|
||||||
<div class="title">
|
<div class="title">
|
||||||
@ -279,6 +280,7 @@ export default {
|
|||||||
},
|
},
|
||||||
cancel() {
|
cancel() {
|
||||||
this.$emit("update:modelValue", false)
|
this.$emit("update:modelValue", false)
|
||||||
|
this.$emit("close")
|
||||||
},
|
},
|
||||||
toggleCall(item) {
|
toggleCall(item) {
|
||||||
item.select = !item.select
|
item.select = !item.select
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import Dom from "../../utils/dom";
|
import Dom from "../../utils/dom";
|
||||||
|
import bus, {EVENT_KEY} from "@/utils/bus";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "FromBottomDialog",
|
name: "FromBottomDialog",
|
||||||
@ -63,6 +64,10 @@ export default {
|
|||||||
type: String,
|
type: String,
|
||||||
default: '5rem 5rem 0 0'
|
default: '5rem 5rem 0 0'
|
||||||
},
|
},
|
||||||
|
tag: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
modelValue(newVal) {
|
modelValue(newVal) {
|
||||||
@ -144,12 +149,13 @@ export default {
|
|||||||
if (this.$refs.dialog.scrollTop !== 0) return
|
if (this.$refs.dialog.scrollTop !== 0) return
|
||||||
this.startLocationY = e.touches[0].pageY
|
this.startLocationY = e.touches[0].pageY
|
||||||
this.startTime = Date.now()
|
this.startTime = Date.now()
|
||||||
|
this.$setCss(this.$refs.dialog, 'transition-duration', `0ms`)
|
||||||
},
|
},
|
||||||
move(e) {
|
move(e) {
|
||||||
if (this.$refs.dialog.scrollTop !== 0) return
|
if (this.$refs.dialog.scrollTop !== 0) return
|
||||||
this.moveYDistance = e.touches[0].pageY - this.startLocationY
|
this.moveYDistance = e.touches[0].pageY - this.startLocationY
|
||||||
if (this.moveYDistance > 0) {
|
if (this.moveYDistance > 0) {
|
||||||
this.$setCss(this.$refs.dialog, 'transition-duration', `0ms`)
|
bus.emit(EVENT_KEY.DIALOG_MOVE, {tag: this.tag, e: this.moveYDistance})
|
||||||
this.$setCss(this.$refs.dialog, 'transform', `translate3d(0,${this.moveYDistance}px,0)`)
|
this.$setCss(this.$refs.dialog, 'transform', `translate3d(0,${this.moveYDistance}px,0)`)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -164,9 +170,11 @@ export default {
|
|||||||
this.$setCss(this.$refs.dialog, 'transition-duration', `250ms`)
|
this.$setCss(this.$refs.dialog, 'transition-duration', `250ms`)
|
||||||
if (Math.abs(this.moveYDistance) > clientHeight / 2) {
|
if (Math.abs(this.moveYDistance) > clientHeight / 2) {
|
||||||
this.$setCss(this.$refs.dialog, 'transform', `translate3d(0,${clientHeight}px,0)`)
|
this.$setCss(this.$refs.dialog, 'transform', `translate3d(0,${clientHeight}px,0)`)
|
||||||
|
bus.emit('dialogEnd', {tag: this.tag, isClose: true})
|
||||||
setTimeout(this.hide, 250)
|
setTimeout(this.hide, 250)
|
||||||
} else {
|
} else {
|
||||||
this.$setCss(this.$refs.dialog, 'transform', `translate3d(0,0,0)`)
|
this.$setCss(this.$refs.dialog, 'transform', `translate3d(0,0,0)`)
|
||||||
|
bus.emit(EVENT_KEY.DIALOG_END, {tag: this.tag, isClose: false})
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.$setCss(this.$refs.dialog, 'transform', 'none')
|
this.$setCss(this.$refs.dialog, 'transform', 'none')
|
||||||
// this.$setCss(this.$refs.dialog, 'transition-duration', `0ms`)
|
// this.$setCss(this.$refs.dialog, 'transition-duration', `0ms`)
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
<img src="../../assets/img/icon/play-white.png" class="pause" v-if="!isPlaying">
|
<img src="../../assets/img/icon/play-white.png" class="pause" v-if="!isPlaying">
|
||||||
<div class="float" :style="{opacity: isUp?0:1}">
|
<div class="float" :style="{opacity: isUp?0:1}">
|
||||||
<div :style="{opacity:isMove ? 0:1}" class="normal">
|
<div :style="{opacity:isMove ? 0:1}" class="normal">
|
||||||
<template v-if="commentVisible">
|
<template v-if="!commentVisible">
|
||||||
<ItemToolbar v-model:item="localItem"
|
<ItemToolbar v-model:item="localItem"
|
||||||
:position="position"
|
:position="position"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
@ -81,7 +81,6 @@ export default {
|
|||||||
ItemToolbar,
|
ItemToolbar,
|
||||||
ItemDesc
|
ItemDesc
|
||||||
},
|
},
|
||||||
inject: ['commentVisible'],
|
|
||||||
provide() {
|
provide() {
|
||||||
return {
|
return {
|
||||||
// isPlaying: computed(() => this.status)
|
// isPlaying: computed(() => this.status)
|
||||||
@ -165,6 +164,7 @@ export default {
|
|||||||
progressBarRect: {},
|
progressBarRect: {},
|
||||||
videoScreenHeight: 0,
|
videoScreenHeight: 0,
|
||||||
videoPoster: `?vframe/jpg/offset/0/w/${document.body.clientWidth}`,
|
videoPoster: `?vframe/jpg/offset/0/w/${document.body.clientWidth}`,
|
||||||
|
commentVisible: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -224,14 +224,52 @@ export default {
|
|||||||
console.log('mounted')
|
console.log('mounted')
|
||||||
// bus.off('singleClickBroadcast')
|
// bus.off('singleClickBroadcast')
|
||||||
bus.on('singleClickBroadcast', this.click)
|
bus.on('singleClickBroadcast', this.click)
|
||||||
// bus.on(EVENT_KEY.TOGGLE_COMMENT, (e) => this.commentVisible = !this.commentVisible)
|
bus.on(EVENT_KEY.DIALOG_MOVE, this.onDialogMove)
|
||||||
|
bus.on(EVENT_KEY.DIALOG_END, this.onDialogEnd)
|
||||||
|
bus.on(EVENT_KEY.OPEN_COMMENTS, this.onOpenComments)
|
||||||
|
bus.on(EVENT_KEY.CLOSE_COMMENTS, this.onCloseComments)
|
||||||
},
|
},
|
||||||
unmounted() {
|
unmounted() {
|
||||||
console.log('unmounted')
|
console.log('unmounted')
|
||||||
bus.off('singleClickBroadcast', this.click)
|
bus.off('singleClickBroadcast', this.click)
|
||||||
// bus.off(EVENT_KEY.TOGGLE_COMMENT,)
|
bus.off(EVENT_KEY.DIALOG_MOVE, this.onDialogMove)
|
||||||
|
bus.off(EVENT_KEY.DIALOG_END, this.onDialogEnd)
|
||||||
|
bus.off(EVENT_KEY.OPEN_COMMENTS, this.onOpenComments)
|
||||||
|
bus.off(EVENT_KEY.CLOSE_COMMENTS, this.onCloseComments)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
onDialogMove({tag, e}) {
|
||||||
|
if (this.commentVisible && tag === 'comment') {
|
||||||
|
Utils.$setCss(this.$refs.video, 'transition-duration', `0ms`)
|
||||||
|
Utils.$setCss(this.$refs.video, 'height', `calc(30vh + ${e}px)`)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onDialogEnd({tag, isClose}) {
|
||||||
|
if (this.commentVisible && tag === 'comment') {
|
||||||
|
console.log('isClose', isClose)
|
||||||
|
Utils.$setCss(this.$refs.video, 'transition-duration', `300ms`)
|
||||||
|
if (isClose) {
|
||||||
|
this.commentVisible = false
|
||||||
|
Utils.$setCss(this.$refs.video, 'height', '100%')
|
||||||
|
} else {
|
||||||
|
Utils.$setCss(this.$refs.video, 'height', '30vh')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onOpenComments(id) {
|
||||||
|
if (id === this.item.id) {
|
||||||
|
Utils.$setCss(this.$refs.video, 'transition-duration', `300ms`)
|
||||||
|
Utils.$setCss(this.$refs.video, 'height', '30vh')
|
||||||
|
this.commentVisible = true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onCloseComments(id) {
|
||||||
|
if (this.commentVisible) {
|
||||||
|
Utils.$setCss(this.$refs.video, 'transition-duration', `300ms`)
|
||||||
|
Utils.$setCss(this.$refs.video, 'height', '100%')
|
||||||
|
this.commentVisible = false
|
||||||
|
}
|
||||||
|
},
|
||||||
click(val) {
|
click(val) {
|
||||||
if (this.item.id === val) {
|
if (this.item.id === val) {
|
||||||
if (this.status === SlideItemPlayStatus.Play) {
|
if (this.status === SlideItemPlayStatus.Play) {
|
||||||
@ -314,6 +352,7 @@ export default {
|
|||||||
video {
|
video {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
transition: height .3s;
|
||||||
/*position: absolute;*/
|
/*position: absolute;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
import BaseMusic from "../BaseMusic";
|
import BaseMusic from "../BaseMusic";
|
||||||
import Utils from "../../utils";
|
import Utils from "../../utils";
|
||||||
import {reactive,} from "vue";
|
import {reactive,} from "vue";
|
||||||
|
import bus, {EVENT_KEY} from "@/utils/bus";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
item: {
|
item: {
|
||||||
@ -43,6 +44,10 @@ function attention(e) {
|
|||||||
}, 1000)
|
}, 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showComments() {
|
||||||
|
bus.emit(EVENT_KEY.OPEN_COMMENTS, props.item.id)
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -65,11 +70,11 @@ function attention(e) {
|
|||||||
</div>
|
</div>
|
||||||
<span>{{ Utils.formatNumber(props.item.digg_count) }}</span>
|
<span>{{ Utils.formatNumber(props.item.digg_count) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="message mb2r" @click.stop="$emit('showComments')">
|
<div class="message mb2r" @click.stop="showComments">
|
||||||
<img src="../../assets/img/icon/message.svg" alt="" class="message-image">
|
<img src="../../assets/img/icon/message.svg" alt="" class="message-image">
|
||||||
<span>{{ Utils.formatNumber(props.item.comment_count) }}</span>
|
<span>{{ Utils.formatNumber(props.item.comment_count) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="message mb2r" @click.stop="$emit('showComments')">
|
<div class="message mb2r" @click.stop="showComments">
|
||||||
<img src="../../assets/img/icon/star-white.png" alt="" class="message-image">
|
<img src="../../assets/img/icon/star-white.png" alt="" class="message-image">
|
||||||
<span>{{ Utils.formatNumber(props.item.comment_count) }}</span>
|
<span>{{ Utils.formatNumber(props.item.comment_count) }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
<H v-model:index="state.baseIndex">
|
<H v-model:index="state.baseIndex">
|
||||||
<SlideItem>
|
<SlideItem>
|
||||||
<IndicatorHome
|
<IndicatorHome
|
||||||
|
v-if="!state.fullScreen"
|
||||||
v-hide="state.isUp"
|
v-hide="state.isUp"
|
||||||
:loading="state.loading"
|
:loading="state.loading"
|
||||||
name="main"
|
name="main"
|
||||||
@ -54,7 +55,9 @@
|
|||||||
</SlideItem>
|
</SlideItem>
|
||||||
</H>
|
</H>
|
||||||
</div>
|
</div>
|
||||||
<Comment page-id="slideHook" v-model="state.commentVisible"/>
|
<Comment page-id="slideHook" v-model="state.commentVisible"
|
||||||
|
@close="closeComments"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="jsx">
|
<script setup lang="jsx">
|
||||||
@ -73,7 +76,7 @@ import {useNav} from "../../utils/hooks/useNav";
|
|||||||
|
|
||||||
const nav = useNav()
|
const nav = useNav()
|
||||||
|
|
||||||
const videos = resource.videos.slice(0, 6).map(v => {
|
const videos = resource.videos.slice(0, 16).map(v => {
|
||||||
v.type = 'recommend-video'
|
v.type = 'recommend-video'
|
||||||
return v
|
return v
|
||||||
})
|
})
|
||||||
@ -114,8 +117,9 @@ const state = reactive({
|
|||||||
shareToFriend: false,
|
shareToFriend: false,
|
||||||
|
|
||||||
commentVisible: false,
|
commentVisible: false,
|
||||||
|
fullScreen: false,
|
||||||
|
style: '100%'
|
||||||
})
|
})
|
||||||
provide('commentVisible', () => state.commentVisible)
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
bus.on('singleClick', () => {
|
bus.on('singleClick', () => {
|
||||||
@ -131,15 +135,25 @@ onMounted(() => {
|
|||||||
state.recommendVideos[itemIndex] = val.item
|
state.recommendVideos[itemIndex] = val.item
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
bus.on(EVENT_KEY.ENTER_FULLSCREEN, (e) => state.fullScreen = true)
|
||||||
|
bus.on(EVENT_KEY.EXIT_FULLSCREEN, (e) => state.fullScreen = false)
|
||||||
|
bus.on(EVENT_KEY.OPEN_COMMENTS, (e) => {
|
||||||
|
bus.emit(EVENT_KEY.ENTER_FULLSCREEN)
|
||||||
|
state.commentVisible = true
|
||||||
|
})
|
||||||
|
bus.on(EVENT_KEY.CLOSE_COMMENTS, (e) => {
|
||||||
|
bus.emit(EVENT_KEY.EXIT_FULLSCREEN)
|
||||||
|
state.commentVisible = false
|
||||||
|
})
|
||||||
bus.on('nav', path => nav(path))
|
bus.on('nav', path => nav(path))
|
||||||
})
|
})
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
bus.offAll()
|
bus.offAll()
|
||||||
})
|
})
|
||||||
|
|
||||||
function test() {
|
function closeComments() {
|
||||||
state.commentVisible = true
|
bus.emit(EVENT_KEY.CLOSE_COMMENTS)
|
||||||
bus.emit(EVENT_KEY.TOGGLE_COMMENT,)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function render(item, itemIndex, play, position) {
|
function render(item, itemIndex, play, position) {
|
||||||
@ -155,7 +169,6 @@ function render(item, itemIndex, play, position) {
|
|||||||
isPlay={false}
|
isPlay={false}
|
||||||
item={item}
|
item={item}
|
||||||
position={{...position, itemIndex}}
|
position={{...position, itemIndex}}
|
||||||
onShowComments={test}
|
|
||||||
onShowShare={e => state.isSharing = true}
|
onShowShare={e => state.isSharing = true}
|
||||||
onGoUserInfo={e => state.baseIndex = 1}
|
onGoUserInfo={e => state.baseIndex = 1}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -41,5 +41,10 @@ export default {
|
|||||||
export const EVENT_KEY = {
|
export const EVENT_KEY = {
|
||||||
ENTER_FULLSCREEN: 'ENTER_FULLSCREEN',
|
ENTER_FULLSCREEN: 'ENTER_FULLSCREEN',
|
||||||
EXIT_FULLSCREEN: 'EXIT_FULLSCREEN',
|
EXIT_FULLSCREEN: 'EXIT_FULLSCREEN',
|
||||||
|
TOGGLE_FULLSCREEN: 'TOGGLE_FULLSCREEN',
|
||||||
TOGGLE_COMMENT: 'TOGGLE_COMMENT',
|
TOGGLE_COMMENT: 'TOGGLE_COMMENT',
|
||||||
|
OPEN_COMMENTS: 'OPEN_COMMENTS',
|
||||||
|
CLOSE_COMMENTS: 'CLOSE_COMMENTS',
|
||||||
|
DIALOG_MOVE: 'DIALOG_MOVE',
|
||||||
|
DIALOG_END: 'DIALOG_END',
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user