小程序 卡片式动效实现

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

相关文章

使用Python和Matplotlib实现可视化字体轮廓(从路径数据到矢量图形)

《使用Python和Matplotlib实现可视化字体轮廓(从路径数据到矢量图形)》字体设计和矢量图形处理是编程中一个有趣且实用的领域,通过Python的matplotlib库,我们可以轻松将字体轮廓... 目录背景知识字体轮廓的表示实现步骤1. 安装依赖库2. 准备数据3. 解析路径指令4. 绘制图形关键

C/C++中OpenCV 矩阵运算的实现

《C/C++中OpenCV矩阵运算的实现》本文主要介绍了C/C++中OpenCV矩阵运算的实现,包括基本算术运算(标量与矩阵)、矩阵乘法、转置、逆矩阵、行列式、迹、范数等操作,感兴趣的可以了解一下... 目录矩阵的创建与初始化创建矩阵访问矩阵元素基本的算术运算 ➕➖✖️➗矩阵与标量运算矩阵与矩阵运算 (逐元

C/C++的OpenCV 进行图像梯度提取的几种实现

《C/C++的OpenCV进行图像梯度提取的几种实现》本文主要介绍了C/C++的OpenCV进行图像梯度提取的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的... 目录预www.chinasem.cn备知识1. 图像加载与预处理2. Sobel 算子计算 X 和 Y

C/C++和OpenCV实现调用摄像头

《C/C++和OpenCV实现调用摄像头》本文主要介绍了C/C++和OpenCV实现调用摄像头,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一... 目录准备工作1. 打开摄像头2. 读取视频帧3. 显示视频帧4. 释放资源5. 获取和设置摄像头属性

c/c++的opencv图像金字塔缩放实现

《c/c++的opencv图像金字塔缩放实现》本文主要介绍了c/c++的opencv图像金字塔缩放实现,通过对原始图像进行连续的下采样或上采样操作,生成一系列不同分辨率的图像,具有一定的参考价值,感兴... 目录图像金字塔简介图像下采样 (cv::pyrDown)图像上采样 (cv::pyrUp)C++ O

c/c++的opencv实现图片膨胀

《c/c++的opencv实现图片膨胀》图像膨胀是形态学操作,通过结构元素扩张亮区填充孔洞、连接断开部分、加粗物体,OpenCV的cv::dilate函数实现该操作,本文就来介绍一下opencv图片... 目录什么是图像膨胀?结构元素 (KerChina编程nel)OpenCV 中的 cv::dilate() 函

Python使用FFmpeg实现高效音频格式转换工具

《Python使用FFmpeg实现高效音频格式转换工具》在数字音频处理领域,音频格式转换是一项基础但至关重要的功能,本文主要为大家介绍了Python如何使用FFmpeg实现强大功能的图形化音频转换工具... 目录概述功能详解软件效果展示主界面布局转换过程截图完成提示开发步骤详解1. 环境准备2. 项目功能结

SpringBoot使用ffmpeg实现视频压缩

《SpringBoot使用ffmpeg实现视频压缩》FFmpeg是一个开源的跨平台多媒体处理工具集,用于录制,转换,编辑和流式传输音频和视频,本文将使用ffmpeg实现视频压缩功能,有需要的可以参考... 目录核心功能1.格式转换2.编解码3.音视频处理4.流媒体支持5.滤镜(Filter)安装配置linu

在Spring Boot中实现HTTPS加密通信及常见问题排查

《在SpringBoot中实现HTTPS加密通信及常见问题排查》HTTPS是HTTP的安全版本,通过SSL/TLS协议为通讯提供加密、身份验证和数据完整性保护,下面通过本文给大家介绍在SpringB... 目录一、HTTPS核心原理1.加密流程概述2.加密技术组合二、证书体系详解1、证书类型对比2. 证书获

Druid连接池实现自定义数据库密码加解密功能

《Druid连接池实现自定义数据库密码加解密功能》在现代应用开发中,数据安全是至关重要的,本文将介绍如何在​​Druid​​连接池中实现自定义的数据库密码加解密功能,有需要的小伙伴可以参考一下... 目录1. 环境准备2. 密码加密算法的选择3. 自定义 ​​DruidDataSource​​ 的密码解密3