小程序 卡片式动效实现

2024-05-10 15:36
文章标签 实现 程序 动效 卡片式

本文主要是介绍小程序 卡片式动效实现,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

效果如下:
在这里插入图片描述
demo:

<!-- 折叠轮播图 组件-->
<template><view class="swpbig"><viewref="swiperPanel"class="swiperPanel"@touchstart="startMove"@touchend="endMove"><viewv-for="(item, index) in swiperList":key="index"class="swiperItem":style="{transform: itemStyle[index].transform, zIndex: itemStyle[index].zIndex, opacity: itemStyle[index].opacity}"><view class="children"><view class="pic"><!-- <span>{{ index }}</span> --><imageclass="pici":src="item.url"/><!--  <imageclass="banner_signal"src="../../static/banner_signal.png"mode=""/> --><view class="swpnew">全新{{ index }}</view></view></view></view></view></view>
</template><script>
var timer
export default {props: {swiperList: {type: Array,default: () => [{type: 'Array'// url: '../../static/banone.png'}, {type: 'Array'// url: '../../static/bantwo.png'}, {type: 'Array'// url: '../../static/banthree.png'}, {type: 'Array'// url: '../../static/banthree.png'}, {type: 'Array'// url: '../../static/banthree.png'}]}},data() {return {slideNote: {x: 0,y: 0},screenWidth: 0,itemStyle: [],active: 0}},created() {var macInfo = uni.getSystemInfoSync()this.screenWidth = macInfo.screenWidth// 计算swiper样式this.swiperList.forEach((item, index) => {this.itemStyle.push(this.getStyle(index))})// timer = setInterval(() => {// this.rightSlider()// }, 3000)},methods: {rightSlider() {var newList = JSON.parse(JSON.stringify(this.itemStyle))var last = [newList.pop()]newList = last.concat(newList)this.itemStyle = newList},getStyle(e, style) {// if (e > this.swiperList.length / 2) {//   console.log(e)//   var right = this.swiperList.length - e//   return {//     transform: 'scale(' + (1 - right / 10) + ') translate(-' + (right * 9) + '%,0px)',//     zIndex: 9999 - right//     // opacity: 0.5 / right//   }// } else {return {transform: 'scale(' + (1 - e / 10) + ') translate(' + (e * 9) + '%,0px)',zIndex: 9999 - e// opacity: 0.5 / e}// }},startMove(e) {clearInterval(timer)this.slideNote.x = e.changedTouches[0] ? e.changedTouches[0].pageX : 0this.slideNote.y = e.changedTouches[0] ? e.changedTouches[0].pageY : 0},endMove(e) {// timer = setInterval(() => {//   this.rightSlider()// }, 3000)let staticTransform = ''let staticActive = ''var newList = JSON.parse(JSON.stringify(this.itemStyle))if ((e.changedTouches[0].pageX - this.slideNote.x) < 0) {staticActive = this.active// 向左滑动var last = [newList.pop()]// console.log('左滑', last)newList = last.concat(newList)const item = newList[staticActive]staticTransform = item.transformitem.transform = 'translateX(-110%) rotate(-10deg)'if (this.active <= this.itemStyle.length - 2) {this.active++} else {this.active = 0}} else if ((e.changedTouches[0].pageX - this.slideNote.x) > 0) {if (this.active === 0) {this.active = this.itemStyle.length - 1} else {this.active--}staticActive = this.active// 向右滑动newList.push(newList[0])newList.splice(0, 1)const item = newList[staticActive]staticTransform = item.transform// item.transform = 'translateX(-110%) rotate(-5deg)'} else {// 点击}this.itemStyle = newListsetTimeout(() => {const item = this.itemStyle[staticActive]item.transform = staticTransform}, 500)}}
}
</script><style lang="scss">.swpbig{overflow: hidden;margin-top: 100px;}.swiperPanel {margin-top: 50upx;height: 680upx;width: 686upx;overflow: hidden;position: relative;margin-left:80upx;.swiperItem {height: 100%;width: 100%;position: absolute;top: 0;left: 0upx;transition: all .5s;.children {// height: 100%;width: 570upx;margin: 2upx 160upx 2upx 0;position: relative;.pic {position: relative;height: 645rpx;width: 560rpx;border-radius: 10upx;}.pici{position: absolute;height: 645rpx;width: 560rpx;border-radius: 10upx;	background: red;}.banner_signal{position: absolute;height: 645rpx;width: 560rpx;top: 0;}.swpnew{position: absolute;height: 63rpx;font-size: 45rpx;font-weight: bold;color: #FFF;line-height: 53rpx;right: 28rpx;margin-top: 12rpx;letter-spacing: 5rpx;}}}}
</style>

这篇关于小程序 卡片式动效实现的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/976851

相关文章

Qt实现对Word网页的读取功能

《Qt实现对Word网页的读取功能》文章介绍了几种在Qt中实现Word文档(.docx/.doc)读写功能的方法,包括基于QAxObject的COM接口调用、DOCX模板替换及跨平台解决方案,重点讨论... 目录1. 核心实现方式2. 基于QAxObject的COM接口调用(Windows专用)2.1 环境

MySQL查看表的历史SQL的几种实现方法

《MySQL查看表的历史SQL的几种实现方法》:本文主要介绍多种查看MySQL表历史SQL的方法,包括通用查询日志、慢查询日志、performance_schema、binlog、第三方工具等,并... 目录mysql 查看某张表的历史SQL1.查看MySQL通用查询日志(需提前开启)2.查看慢查询日志3.

Java实现字符串大小写转换的常用方法

《Java实现字符串大小写转换的常用方法》在Java中,字符串大小写转换是文本处理的核心操作之一,Java提供了多种灵活的方式来实现大小写转换,适用于不同场景和需求,本文将全面解析大小写转换的各种方法... 目录前言核心转换方法1.String类的基础方法2. 考虑区域设置的转换3. 字符级别的转换高级转换

使用Python实现局域网远程监控电脑屏幕的方法

《使用Python实现局域网远程监控电脑屏幕的方法》文章介绍了两种使用Python在局域网内实现远程监控电脑屏幕的方法,方法一使用mss和socket,方法二使用PyAutoGUI和Flask,每种方... 目录方法一:使用mss和socket实现屏幕共享服务端(被监控端)客户端(监控端)方法二:使用PyA

MyBatis-Plus逻辑删除实现过程

《MyBatis-Plus逻辑删除实现过程》本文介绍了MyBatis-Plus如何实现逻辑删除功能,包括自动填充字段、配置与实现步骤、常见应用场景,并展示了如何使用remove方法进行逻辑删除,逻辑删... 目录1. 逻辑删除的必要性编程1.1 逻辑删除的定义1.2 逻辑删php除的优点1.3 适用场景2.

C#借助Spire.XLS for .NET实现在Excel中添加文档属性

《C#借助Spire.XLSfor.NET实现在Excel中添加文档属性》在日常的数据处理和项目管理中,Excel文档扮演着举足轻重的角色,本文将深入探讨如何在C#中借助强大的第三方库Spire.... 目录为什么需要程序化添加Excel文档属性使用Spire.XLS for .NET库实现文档属性管理Sp

Python+FFmpeg实现视频自动化处理的完整指南

《Python+FFmpeg实现视频自动化处理的完整指南》本文总结了一套在Python中使用subprocess.run调用FFmpeg进行视频自动化处理的解决方案,涵盖了跨平台硬件加速、中间素材处理... 目录一、 跨平台硬件加速:统一接口设计1. 核心映射逻辑2. python 实现代码二、 中间素材处

Java数组动态扩容的实现示例

《Java数组动态扩容的实现示例》本文主要介绍了Java数组动态扩容的实现示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧... 目录1 问题2 方法3 结语1 问题实现动态的给数组添加元素效果,实现对数组扩容,原始数组使用静态分配

Python实现快速扫描目标主机的开放端口和服务

《Python实现快速扫描目标主机的开放端口和服务》这篇文章主要为大家详细介绍了如何使用Python编写一个功能强大的端口扫描器脚本,实现快速扫描目标主机的开放端口和服务,感兴趣的小伙伴可以了解下... 目录功能介绍场景应用1. 网络安全审计2. 系统管理维护3. 网络故障排查4. 合规性检查报错处理1.

Python轻松实现Word到Markdown的转换

《Python轻松实现Word到Markdown的转换》在文档管理、内容发布等场景中,将Word转换为Markdown格式是常见需求,本文将介绍如何使用FreeSpire.DocforPython实现... 目录一、工具简介二、核心转换实现1. 基础单文件转换2. 批量转换Word文件三、工具特性分析优点局