HomeDocs
Skip to main content

short-videos-view

Introduction

A scrollable container for short videos. It is used in conjunction with the native-video component to implement short video functionality, primarily for handling the switching of videos.

Property Description

Property NameTypeDefaultRequiredDescription
scroll-with-animationBooleanFALSENoSpecifies whether to use animation when switching videos.
scroll-animation-durationNumber200NoThe duration (in milliseconds) of the animation when switching videos.
scroll-damping-coefficientNumber0NoThe damping coefficient for page scrolling when swiping with a finger.
toggle-thresholdNumber0.2NoThe threshold for switching videos when swiping.
verticalBooleantrueNoSpecifies whether to scroll vertically.
active-indexNumber0NoSets the index of the currently displayed video.
onchangeEventHandle-NoTriggered when the video is switched. The index and current index are passed as parameters.

Examples

<short-videos-view
:scroll-with-animation="scrollWithAnimation"
:scroll-damping-coefficient="scrollDampingCoefficient"
:toggle-threshold="toggleThreshold"
:break-auto-scroll="breakAutoScroll"
bind:onchange="onChange"
>
<view>
<view class="item" :key="index" s-for="(item, index) in list"
>{{ item }}</view
>
</view>
</short-videos-view>
Page({
data: {
list: [1, 2, 3],
scrollWithAnimation: true,
scrollDampingCoefficient: 0.4,
toggleThreshold: 0.05,
breakAutoScroll: false,
},
onLoad() {
setTimeout(() => {
this.setData({
list: [1, 2, 3],
});
}, 2000);
},
onChange(index) {
const { list } = this.data;
const len = list.length;
if (index >= len - 2 && len < 18) {
this.setData({
list: list.concat([len + 1, len + 2, len + 3]),
});
}
console.log('index===', index);
},
onPullDownRefresh() {
this.setData({
list: [1, 2, 3],
});
setTimeout(() => {
dlt.stopPullDownRefresh();
}, 200);
},
onReachBottom() {
setTimeout(() => {
dlt.stopPullUpRefresh();
dlt.showToast('no more data');
}, 200);
},
});
.item {
width: 100vw;
height: 100vh;
}

.item:nth-child(3n) {
background: #0081ff;
}
.item:nth-child(3n + 1) {
background: #00d7ae;
}
.item:nth-child(3n + 2) {
color: #191f2b;
background: #e4e6eb;
}
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.