微信小程序仿胖东来轮播和背景效果(有效果图)

news/2024/9/24 3:27:39/

效果图

请添加图片描述

.wxml

<view class="swiper-index" style="--width--:{{windowWidth}}px;"><image src="{{swiperList[(cardCur + bgIndex == -1?swiperList.length - 1:cardCur + bgIndex > swiperList.length -1?0:cardCur + bgIndex)]}}" class="swiper-bg" style="--filter--:blur({{(1 - radio) * 12}}px);"></image><swiper class="card-swiper square-dot" indicator-dots="true" circular="{{true}}" autoplay="{{true}}" style="--scale--:{{radio}};"interval="{{5000}}" duration="500"  indicator-color="#ffffff" indicator-active-color="#F2F2F2"bindtransition="cardSition" bindanimationfinish="cardFinish"data-windowWidth="{{windowWidth}}" data-bgindex="{{bgIndex}}"><swiper-item wx:for="{{swiperList}}" wx:key="index" class="{{cardCur==index?'cur':''}}"><view class="swiper-item"><image class="swiper-image" src="{{item}}"></image></view></swiper-item></swiper>
</view>
<view style="background: #fff;height: 10px;"></view>

.js

Page({data: {swiperList: ['https://ossweb-img.qq.com/images/lol/web201310/skin/big84000.jpg','https://ossweb-img.qq.com/images/lol/web201310/skin/big84001.jpg','https://ossweb-img.qq.com/images/lol/web201310/skin/big10001.jpg'],cardCur:0,windowWidth:wx.getSystemInfoSync().windowWidth,radio:1,bgIndex:'',},cardFinish(e){this.setData({radio:1,bgIndex:0,cardCur: e.detail.current,})},cardSition(e){let dx = Math.abs(e.detail.dx),windowWidth = e.currentTarget.dataset.windowwidth,bgindex = e.currentTarget.dataset.bgindex;let num = dx / windowWidthlet radio = 1 - num < 0.9?0.9:1 - num;let index = num > 0.45?(e.detail.dx < 0?-1:1):0this.setData({radio,})if(index != bgindex){this.setData({bgIndex:index,})}},
})

.wxss

view,scroll-view,swiper,image {box-sizing: border-box;}
.swiper-index{padding: 10px;height: 260px;padding-top:100px;position: relative;}
.swiper-index::after{content: '';width: 120%;position: absolute;left: -10%;bottom: -30px;height: 30px;box-shadow: 0 -15px 15px 0px rgba(255,255,255,0.6);}
.swiper-bg{position: absolute;left: 0;top: 0;width: 100%;height: 100%;filter: var(--filter--);z-index: -1;
transition: all 0.3s;}
.card-swiper {height: 130px !important;width: 100%;}
.card-swiper swiper-item {overflow: hidden;border-radius: 20rpx;}
.swiper-image{width:var(--width--);height: 260px;position: absolute;left: -10px;top: -100px;}
.card-swiper swiper-item .swiper-item {width: 100%;display: block;height: 100%;
transition: all 0.2s ease-in 0s;overflow: hidden;}
.card-swiper swiper-item.cur .swiper-item {transform: none;transform: scale(var(--scale--));
transition: all 0.1s ease-in 0s;border-radius: 20rpx;}
swiper.square-dot .wx-swiper-dot {background-color: #fff;opacity: 0.4;width: 10rpx;
height: 10rpx;border-radius: 20rpx;margin: 0 8rpx !important;}
swiper.square-dot .wx-swiper-dot.wx-swiper-dot-active {opacity: 1;width: 30rpx;}

遇到问题可以看我主页加我Q,很少看博客,对你有帮助别忘记点赞收藏。


http://www.ppmy.cn/news/1463712.html

相关文章

Golang | Leetcode Golang题解之第110题平衡二叉树

题目&#xff1a; 题解&#xff1a; func isBalanced(root *TreeNode) bool {return height(root) > 0 }func height(root *TreeNode) int {if root nil {return 0}leftHeight : height(root.Left)rightHeight : height(root.Right)if leftHeight -1 || rightHeight -1 …

Flutter 中的 ConstrainedBox 小部件:全面指南

Flutter 中的 ConstrainedBox 小部件&#xff1a;全面指南 在 Flutter 的世界中&#xff0c;布局小部件扮演着至关重要的角色&#xff0c;它们帮助开发者以声明式的方式构建用户界面。ConstrainedBox 是其中一种强大的布局小部件&#xff0c;它允许开发者对子组件的尺寸施加额…

由于删除、修改、重装QT库引起的软件问题@FreeBSD

由于由于删除、修改、重装QT库以及snappy库等&#xff0c;导致很多软件出现了异常&#xff0c;即无法启动&#xff0c;逐个解决问题。 qutebrowser浏览器 报错&#xff1a; qutebrowser报错 No backend library found qutebrowser needs QtWebKit or QtWebEngine, but neith…

电路笔记 :元器件焊接相关 酒精灯松香浴加热取芯片

记录一下只使用松香和小火源加热&#xff08;如酒精灯、小蜡烛&#xff09;从电路板中取芯片。 过程 多放松香 让松香淹没芯片尽量均匀加热&#xff0c;等芯片旁边的松香开始从芯片里冒细小的“泡泡”&#xff0c;就差不多了 注&#xff1a;这种方法也可以用于焊接&#xff0…

golang调用aliyun的语音通话服务,复制直接使用

golang调用aliyun的语音通话服务 通过API使用语音通知/语音验证码——阿里云官方文档SingleCallByTts - 发送语音验证码或文本转语音类型的语音通知入门流程主要参数引入阿里云语音官方SDK-go版本完整代码通过API使用语音通知/语音验证码——阿里云官方文档 https://help.aliy…

C数据结构:二叉树

目录 二叉树的数据结构 前序遍历 中序遍历 后序遍历 二叉树的创建 二叉树的销毁 二叉树的节点个数 二叉树叶子节点个数 二叉树第K层节点个数 二叉树的查找 层序遍历 判断二叉树是否为完全二叉树 完整代码 二叉树的数据结构 typedef char BTDataType; typedef str…

vue-封装上下(垂直方向)轮播

需求&#xff1a;没有找到特别好的上下轮播插件-所以自己写了一个简单的demo 一.上下平滑轮播-移入停止-移出继续轮播 <!--* 消息滚动 --> <template><div class"news"><div id"roll" class"InfoBox" mouseover"thi…

java新特性(Stream API)

什么是 Stream API? Stream API 是 Java 8 引入的一个用于对集合数据进行函数式编程操作的强大的库。它允许我们以一种更简洁、易读、高效的方式来处理集合数据,可以极大提高 Java 程序员的生产力,是目前为止对 Java 类库最好的补充。 Stream API 的核心思想是将数据处理操作…