From b2daccf1069407fdeaa60bc6cd253110c6e65f6b Mon Sep 17 00:00:00 2001 From: zyronon Date: Mon, 28 Mar 2022 01:17:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=A7=86=E9=A2=91=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/BVideo.vue | 21 +++++++++++---------- src/pages/slide/SlideVerticalInfinite.vue | 1 + src/utils/mixin.js | 4 ++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/components/BVideo.vue b/src/components/BVideo.vue index 329d27b..be6b400 100644 --- a/src/components/BVideo.vue +++ b/src/components/BVideo.vue @@ -195,6 +195,7 @@ export default { line: null, point: null, isMove: false, + isSingleClick: false, test: [1, 2], lVideo: this.video, @@ -210,15 +211,14 @@ export default { let video = this.$refs.video video.currentTime = 0 let fun = e => { - this.loading = false this.currentTime = Math.ceil(e.target.currentTime) this.pageX = this.currentTime * this.step } video.addEventListener('loadedmetadata', e => { this.videoScreenHeight = video.videoHeight / (video.videoWidth / this.width) this.duration = video.duration - // if (this.duration > 60) { - if (this.duration > 6) { + if (this.duration > 60) { + // if (this.duration > 6) { this.step = this.width / Math.floor(this.duration) video.addEventListener('timeupdate', fun) } @@ -228,14 +228,11 @@ export default { video.addEventListener(e, () => { if (e === 'playing') this.loading = false if (e === 'waiting') { - // console.log('paused',this.paused) - console.log('!this.paused ', !this.paused) - console.log(' !this.isPlaying', !this.isPlaying) - if (!this.paused && !this.isPlaying) { + if (!this.paused && !this.isSingleClick) { this.loading = true } } - console.log(e, t) + // console.log(e, t) }, false); } @@ -270,10 +267,13 @@ export default { videoWrapper.on('singleClick', () => { if (this.isPlaying) { this.pause() - this.paused = true } else { this.play() - this.paused = false + //这里playg事件,触发之后,会马上触发一次waiting事件。就很烦,会出现点完播放之后闪一下loading的情况,所以用一个变量来规避一下 + this.isSingleClick = true + setTimeout(()=>{ + this.isSingleClick = false + },300) } this.loading = false }) @@ -305,6 +305,7 @@ export default { new Dom(`.${this.name}-music`).trigger('pause') // console.log('trigger-pause') this.$refs.video.pause() + this.paused = true this.isPlaying = false }, $likeNum(v) { diff --git a/src/pages/slide/SlideVerticalInfinite.vue b/src/pages/slide/SlideVerticalInfinite.vue index 9c73d7f..d4269ec 100644 --- a/src/pages/slide/SlideVerticalInfinite.vue +++ b/src/pages/slide/SlideVerticalInfinite.vue @@ -155,6 +155,7 @@ export default { this.startY = e.touches[0].pageY this.startTime = Date.now() }, + //TODO 2022-3-28:在最顶部,反复滑动会抖动一下,初步猜测是因为方向变了,导致的加判断距离变成了减 touchMove(e) { this.moveX = e.touches[0].pageX - this.startX this.moveY = e.touches[0].pageY - this.startY diff --git a/src/utils/mixin.js b/src/utils/mixin.js index 643914f..4361872 100644 --- a/src/utils/mixin.js +++ b/src/utils/mixin.js @@ -142,13 +142,13 @@ export default { } } let check = (e) => { - let checkTime = 400 + let checkTime = 300 if (isDbClick) { dbClick(e) clearTimeout(dbClickTimer); dbClickTimer = setTimeout(() => { isDbClick = false - }, 400); + }, checkTime); return } let nowTime = new Date().getTime();