29272
This commit is contained in:
@@ -2,7 +2,8 @@
|
|||||||
<div :class="wrapper" class="canvas" v-if="isInit" style="height: 52px">
|
<div :class="wrapper" class="canvas" v-if="isInit" style="height: 52px">
|
||||||
<canvas class="canvas" :id="id" :canvas-id="id" :style="{width: canvasWidth + 'px', height: canvasHeight + 'px'}" v-if="canvasWidth" :width="canvasWidth" @click.stop="onClick" :height="canvasHeight">
|
<canvas class="canvas" :id="id" :canvas-id="id" :style="{width: canvasWidth + 'px', height: canvasHeight + 'px'}" v-if="canvasWidth" :width="canvasWidth" @click.stop="onClick" :height="canvasHeight">
|
||||||
</canvas>
|
</canvas>
|
||||||
<img class="drag-img" :style="{left: x + 'px'}" src="https://cdn.cunwuyun.cn/slw2.0/images/drag.png" />
|
<em :style="{height: '24px', left: x + 'px'}"></em>
|
||||||
|
<img class="drag-img" :style="{ left: x + 'px'}" @touchstart="touchstart" @touchmove="touchmove" @touchend="touchend" src="https://cdn.cunwuyun.cn/slw2.0/images/drag.png" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -55,23 +56,36 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onMousemove (e) {
|
touchmove (e) {
|
||||||
const canvasInfo = document.querySelector(`#${this.id}`).getBoundingClientRect()
|
console.log(e)
|
||||||
const seconds = 24 * 60 * 60
|
this.x = e.touches[0].clientY
|
||||||
|
// const canvasInfo = document.querySelector(`#${this.id}`).getBoundingClientRect()
|
||||||
|
// const seconds = 24 * 60 * 60
|
||||||
|
|
||||||
if (e.clientY - canvasInfo.top < 29) {
|
// if (e.clientY - canvasInfo.top < 29) {
|
||||||
const x = e.clientX - canvasInfo.left
|
// const x = e.clientX - canvasInfo.left
|
||||||
const unit = seconds / this.canvasWidth * x
|
// const unit = seconds / this.canvasWidth * x
|
||||||
this.left = x
|
// this.left = x
|
||||||
this.time = this.secTotime(unit)
|
// this.time = this.secTotime(unit)
|
||||||
this.isHide = false
|
// this.isHide = false
|
||||||
|
|
||||||
if (!this.isChoose) return
|
// if (!this.isChoose) return
|
||||||
this.x = e.clientX - canvasInfo.left
|
// this.x = e.clientX - canvasInfo.left
|
||||||
this.ratioW = this.x / this.canvasWidth
|
// this.ratioW = this.x / this.canvasWidth
|
||||||
} else {
|
// } else {
|
||||||
this.isHide = true
|
// this.isHide = true
|
||||||
}
|
// }
|
||||||
|
},
|
||||||
|
|
||||||
|
touchstart (e) {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
touchend (e) {
|
||||||
|
clearInterval(this.timer)
|
||||||
|
this.timer = null
|
||||||
|
const time = this.secTotime((24 * 60 * 60) / this.canvasWidth * this.x)
|
||||||
|
this.$emit('replay', time)
|
||||||
},
|
},
|
||||||
|
|
||||||
onClick (e) {
|
onClick (e) {
|
||||||
@@ -232,6 +246,16 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
|
& > em {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 11;
|
||||||
|
width: 4px;
|
||||||
|
height: 24px;
|
||||||
|
background: #fff;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
|
||||||
.drag-img {
|
.drag-img {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user