当前位置:网站首页>Uni app swiper rotation chart (full screen / card)
Uni app swiper rotation chart (full screen / card)
2022-06-26 03:43:00 【yyxhzdm】
design sketch :


1. Custom components bw-swiper.vue Code :
<template>
<view class="swiperContent">
<swiper
@change="change"
@animationfinish="animationfinish"
:indicator-dots="indicatorDots"
:indicator-active-color="indicatorActiveColor"
:indicator-color="indicatorColor"
:current="current"
:interval="interval"
:duration="duration"
:circular="circular"
:vertical="vertical"
:previous-margin="previousMargin"
:next-margin="nextMargin"
:display-multiple-items="displayMultipleItems"
:skip-hidden-item-layout="skipHiddenItemLayout"
:autoplay="(autoplay && flag)"
:style="{'height':swiperHeight+'px'}"
:class="(swiperType && displayMultipleItems ==1 && !vertical && !fullScreen)?'cardSwiper':'' "
class="screen-swiper"
>
<swiper-item class="swiper-item" v-for="(item,index) in swiperList" :key="index" :class="(cardCur==index && displayMultipleItems ==1 && !vertical && !fullScreen)?'cur':''" @tap="clickItem(index)">
<view v-if="item[imageKey] && !item[videoKey]">
<image :src="item[imageKey]" :style="{'height':swiperHeight+'px'}"></image>
<text v-if="textTip" class="swiperText" :style="{
'bottom':(swiperType?(textStyleBottom+12):textStyleBottom)+'%',
'right':textStyleRight+'%',
'color':textStyleColor,
'background':textStyleBgcolor,
'font-size':upxtopx(textStyleSize)
}">{ {item[textKey]}}</text>
</view>
<view v-if="item[videoKey]">
<video :src="item[videoKey]" @play="play" @pause="pause" :style="{'height':swiperHeight+'px'}" autoplay loop muted :autoplay="videoAutoplay" objectFit="cover"></video>
</view>
</swiper-item>
<swiper-item class="swiper-item" v-if="swiperList.length==0" >
<text></text>
</swiper-item>
</swiper>
</view>
</template>
<script>
export default {
name:'bw-swiper',
created:function(){
var that = this;
if(this.fullScreen){
uni.getSystemInfo({
success:function(e){
that.swiperHeight = e.screenHeight -44
}})
}
},
mounted:function(){
if(!this.fullScreen){
const query = uni.createSelectorQuery().in(this);
query.select('.swiper-item').boundingClientRect(data => {
if(!!data){
this.swiperHeight = data.width/this.w_h;
}
}).exec();
}
},
props: {
fullScreen:{ // Is it full screen
type:Boolean,
default:false
},
swiperList:{ // Slider view container data
type:Array,
required: true,
default:function(){
return []
}
},
swiperType:{ // false => Full screen height limit rotation chart true => Kata carousel
type:Boolean,
default:false
},
videoAutoplay:{ // true =>video Auto play
type:Boolean,
default:false
},
videoKey:{ // Keys for video mapping
type:String,
default:'src'
},
imageKey:{ // Key of image mapping
type:String,
default:'img'
},
textKey:{ // The key of the text description mapping
type:String,
default:'text'
},
textTip:{ // Picture caption false => hide
type:Boolean,
default:false
},
textStyleSize:{ // Picture text size
type:Number,
default:24
},
textStyleBottom:{ // Picture text position
type:Number,
default:5
},
textStyleRight:{ // Picture text position
type:Number,
default:5
},
textStyleColor:{ // Picture text color
type:String,
default:'#ffffff'
},
textStyleBgcolor:{ // Picture text background color
type:String,
default:'transparent'
},
w_h:{ // Aspect ratio recommend w/h => 2
type:Number,
default:2
},
skipHiddenItemLayout:{ // Do you want to skip the slide layout that is not shown , Set to true It can optimize the sliding performance in complex situations , But the layout information of the hidden state slider will be lost
type:Boolean,
default:false
},
displayMultipleItems:{ // Number of sliders displayed at the same time
type:Number,
default:1
},
nextMargin:{ // Back margin , Can be used to expose a small part of the latter , Accept px and rpx value Headline applet not supported
type:String,
default:'0px'
},
previousMargin:{// Front margin , Can be used to expose a small part of the previous item , Accept px and rpx Value header applet does not support
type:String,
default:'0px'
},
vertical:{ // Whether the sliding direction is longitudinal The card Vertical and simultaneous display are not supported 2 Number of blocks or more
type:Boolean,
default:false
},
circular:{ // Whether to adopt the joint sliding
type:Boolean,
default:true
},
duration:{ // The length of the slide animation
type:Number,
default:400
},
interval:{ // Auto switch interval
type:Number,
default:2500
},
current:{ // The current slider index
type:Number,
default:0
},
autoplay:{ // Auto switch or not -- Wheel planting
type:Boolean,
default:false
},
indicatorColor:{ // Indicate the color
type:String,
default:'#CCCCCC'
},
indicatorActiveColor: { // The currently selected indicator color
type: String,
default: '#ffffff'
},
indicatorDots: { // Display panel indicator
type: Boolean,
default: true
}
},
data() {
return {
flag:true,
cardCur:0,
swiperHeight:300
}
},
computed:{
},
methods: {
upxtopx:function(size){
// #ifdef MP-WEIXIN
return uni.upx2px(size)+'px'
// #endif
// #ifndef MP-WEIXIN
return size+'upx';
// #endif
},
play:function(){
this.flag = false
},
pause:function(){
this.flag = true
},
clickItem:function(index){
if(this.swiperList.length>0){
this.$emit('clickItem',this.swiperList[index])
}
},
change:function(e){
this.$emit('change',e)
},
animationfinish:function(e){
this.cardCur = e.detail.current;
this.$emit('animationfinish',e)
}
}
}
</script>
<style>
.cardSwiper .swiper-item{
width:86%!important;
overflow: initial;
}
.cardSwiper .swiper-item view{
width: 100%;
display: block;
height: 100%;
border-radius: 10upx;
transform: scale(0.9,0.8);
opacity: 0.7;
transition: all 0.1s ease-in 0s;
overflow: hidden;
box-sizing: border-box;
margin-left:8.1%;
}
.cardSwiper .cur view{
transform: initial;
opacity: 1;
transition: all 0.1s ease-in 0s;
}
.swiper-item view{
height:100%;
width:100%;
position: relative;
}
.swiperText{
position: absolute;
color:#ffffff;
z-index:2;
border-radius: 4upx;
padding:0 4upx;
}
.screen-swiper image{
width:100%;
}
.screen-swiper video,
.swiper-item video {
width: 100%;
display: block;
height: 100%;
}
.swiperContent{
width:100%;
}
</style>
2. Call of custom component :
Code :
<template>
<view class="content">
<bwSwiper :swiperList="swiperList" style="width:100%" :swiperType="true" :autoplay="false"></bwSwiper>
</view>
</template>
<script>
import bwSwiper from "../../comment/bw-swiper/bw-swiper.vue"
export default {
components: {
bwSwiper
},
data() {
return {
swiperList: [{
img: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big25011.jpg'
},
{
img: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big25011.jpg'
},
{
img: 'https://ossweb-img.qq.com/images/lol/web201310/skin/big25011.jpg'
}
]
}
},
methods: {
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: white;
width: 100%;
height: 100%;
}
page {
background-color: white;
}
</style>
explain :

resources Demo
https://download.csdn.net/download/yyxhzdm/26321747?spm=1001.2014.3001.5503
边栏推荐
猜你喜欢

QT compilation error: unknown module (s) in qt: script
![[paper notes] supersizing self supervision: learning to grasp from 50K tries and 700 robot hours](/img/fe/f8208747e03133f4a66e73598409d5.png)
[paper notes] supersizing self supervision: learning to grasp from 50K tries and 700 robot hours

Classic model - Nin & googlenet

Mysql database foundation

点击事件

Hardware creation principle of campus maker space

请求对象,发送请求

kotlin快速上手
HL7Exception: Can‘t XML-encode a GenericMessage. Message must have a recognized struct

Uni app custom drop-down selection list
随机推荐
HL7Exception: Can‘t XML-encode a GenericMessage. Message must have a recognized struct
String到底能不能改变?
Pay attention to the entrance components of official account in the applet
Double carbon bonus + great year of infrastructure construction 𞓜 deep ploughing into the field of green intelligent equipment for water conservancy and hydropower
Is it safe for Caicai securities to open an account in 2022?
Asynctask multiple simultaneous use methods
Add an "open search description" to the site to adapt to the browser's "site search"“
显卡、GPU、CPU、CUDA、显存、RTX/GTX及查看方式
Review of the paper: unmixing based soft color segmentation for image manipulation
小米电视的网页和珠宝的网页
解决uniapp插件robin-editor设置字体颜色和背景颜色报错的问题
开通基金账户是安全的吗?怎么申请呢
指南针app是正规的吗?到底安不安全
[hash table] improved, zipper hash structure - directly use two indexes to search, instead of hashing and% every time
动态线段树leetcode.715
路由跳转之点击列表的操作按钮,跳转至另一个菜单页面并激活相应的菜单
Tupu software is the digital twin of offshore wind power, striving to be the first
Dynamic segment tree leetcode seven hundred and fifteen
MySQL development environment
Do you want to add a key to the applet or for sequence?