78 lines
1.3 KiB
Vue
78 lines
1.3 KiB
Vue
|
<script setup>
|
||
|
/**
|
||
|
* 视频进度条
|
||
|
*/
|
||
|
import {
|
||
|
ref,
|
||
|
defineEmits,
|
||
|
} from 'vue';
|
||
|
|
||
|
// 接收
|
||
|
const props = defineProps({
|
||
|
progress: {
|
||
|
type: [Number, String],
|
||
|
default: 0,
|
||
|
},
|
||
|
item: {
|
||
|
type: Object,
|
||
|
},
|
||
|
})
|
||
|
|
||
|
// 触发
|
||
|
const emit = defineEmits(['change', 'end'])
|
||
|
// 拖拽开关
|
||
|
const trigger = ref(false)
|
||
|
|
||
|
// 开始触摸
|
||
|
function onStart() {
|
||
|
//
|
||
|
}
|
||
|
|
||
|
// 触摸移动
|
||
|
function onMove(ev) {
|
||
|
// console.log('move', ev)
|
||
|
}
|
||
|
|
||
|
// 移动结束
|
||
|
function onEnd(ev) {
|
||
|
// console.log('end', ev)
|
||
|
// 拖拽结束时的像素位置
|
||
|
const end = ev.changedTouches[0].screenX
|
||
|
//
|
||
|
let result = 750 / end
|
||
|
console.log('item', props.item)
|
||
|
emit('end')
|
||
|
//
|
||
|
return
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<template>
|
||
|
<view class="durationBox" @touchstart.stop="onStart" @touchmove.stop="onMove" @touchend.stop="onEnd">
|
||
|
<view class="duration">
|
||
|
<view class="line" :style="{ width: progress + 'rpx' }"></view>
|
||
|
</view>
|
||
|
</view>
|
||
|
</template>
|
||
|
|
||
|
<style lang="scss" scoped>
|
||
|
// 视频时长
|
||
|
.durationBox {
|
||
|
padding-top: 60rpx;
|
||
|
// background-color: red;
|
||
|
// z-index: 10;
|
||
|
|
||
|
.duration {
|
||
|
width: 750rpx;
|
||
|
background-color: rgba(255, 255, 255, .3);
|
||
|
|
||
|
// 时间时长
|
||
|
.line {
|
||
|
width: 0;
|
||
|
height: 2rpx;
|
||
|
background-color: rgba(255, 255, 255, .8);
|
||
|
transition-duration: .25s;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</style>
|