Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mini-program-wepy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ui
mini-program-wepy
Commits
6e4d57c7
Commit
6e4d57c7
authored
Jul 08, 2020
by
郭志伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: video-swiper切换优化
parent
1e47e363
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
21 deletions
+22
-21
video.wpy
src/components/custom/video.wpy
+22
-21
No files found.
src/components/custom/video.wpy
View file @
6e4d57c7
...
@@ -2,12 +2,11 @@
...
@@ -2,12 +2,11 @@
<view class="container">
<view class="container">
<swiper
<swiper
class="video-swiper"
class="video-swiper"
duration="
6
00"
duration="
3
00"
circular="{{circular}}"
circular="{{circular}}"
vertical
vertical
current="1"
current="1"
bindchange="moveSwiper"
bindchange="moveSwiper">
bindanimationfinish="animationfinish">
<swiper-item wx:for="{{curQueue}}" wx:key="index">
<swiper-item wx:for="{{curQueue}}" wx:key="index">
<view class="video-swiper">
<view class="video-swiper">
<video
<video
...
@@ -45,13 +44,15 @@
...
@@ -45,13 +44,15 @@
</view>
</view>
</swiper-item>
</swiper-item>
</swiper>
</swiper>
<van-popup show="{{showPopup}}" close-on-click-overlay="{{false}}" overlay-style="background-color:transparent"></van-popup>
</view>
</view>
</template>
</template>
<script>
<script>
import wepy from '@wepy/core';
import wepy from '@wepy/core';
import { getProbability } from '../../common/raffleProbability';
import { getProbability } from '../../common/raffleProbability';
import { getAwardsDetail, getPrizeList } from '../../common/api.js';
import { getAwardsDetail, getPrizeList } from '../../common/api.js';
let playTimer = null;
wepy.component({
wepy.component({
props: {
props: {
videoList: {
videoList: {
...
@@ -77,7 +78,6 @@
...
@@ -77,7 +78,6 @@
_videoContexts: [],
_videoContexts: [],
currentIndex: 1,
currentIndex: 1,
videoPause: false,
videoPause: false,
showPopup: false,
videoLoading: true
videoLoading: true
},
},
watch: {
watch: {
...
@@ -147,11 +147,6 @@
...
@@ -147,11 +147,6 @@
this.videoPause = false;
this.videoPause = false;
this.videoLoading = true;
this.videoLoading = true;
if (e.$wx.detail.source === 'touch') {
if (e.$wx.detail.source === 'touch') {
// 增加一个透明遮罩层,控制用户滑动速度,500ms内只能滑动一次,解决用户滑动过快,不触发animationfinish的bug
this.showPopup = true;
setTimeout(() => {
this.showPopup = false;
}, 500);
const current = e.$wx.detail.current;
const current = e.$wx.detail.current;
this.currentIndex = current;
this.currentIndex = current;
// 如果next中如果就剩下4个了,请求下一页
// 如果next中如果就剩下4个了,请求下一页
...
@@ -160,6 +155,7 @@
...
@@ -160,6 +155,7 @@
this._videoListChanged(data);
this._videoListChanged(data);
});
});
}
}
this.animationfinish(e);
}
}
},
},
animationfinish (e) {
animationfinish (e) {
...
@@ -221,18 +217,23 @@
...
@@ -221,18 +217,23 @@
this.circular = circular;
this.circular = circular;
},
},
playCurrent (current) {
playCurrent (current) {
this.curQueue[current] && this.getProgress(this.curQueue[current].id);
this.$nextTick(() => {
// 滑动到当前元素时,其他video都暂停,只播放当前video
if (playTimer) clearTimeout(500);
this._videoContexts.forEach(function (ctx, index) {
playTimer = setTimeout(() => {
if (ctx) {
this.curQueue[current] && this.getProgress(this.curQueue[current].id);
if (index !== current) {
// 滑动到当前元素时,其他video都暂停,只播放当前video
ctx.pause();
this._videoContexts.forEach(function (ctx, index) {
} else {
if (ctx) {
ctx.play();
if (index !== current) {
}
ctx.pause();
}
} else {
ctx.play();
}
}
});
this.updateAwardsInfo(current);
}, 500);
});
});
this.updateAwardsInfo(current);
},
},
videoTap(e) {
videoTap(e) {
const current = e.currentTarget.dataset.index;
const current = e.currentTarget.dataset.index;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment