• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

微信小程序卡片动画for循环

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

wxml页面:

 1 <view class="container">
 2     <view wx:for="{{info}}" data-index="{{index}}" class="card" id="{{item.id}}" style="position: absolute; left:{{item.left}}rpx; top:{{item.top + index*10}}rpx;display:{{display1}}; z-index:{{100-index}}; opacity:1;" bindtouchstart="viewTouchInside" bindtouchmove="viewDidMove" bindtouchend="viewTouchUpDownInside" animation="{{item.animation}}">
 3         <view style="width:100%;height:auto;margin-top:13%;"><rich-text nodes="{{item.profile}}"></rich-text></view>
 4     </view>
 5     <view style="height:100rpx;width:100%;  position: fixed;bottom:100rpx;">
 6         <view class="left-view" bindtap="LastPage" ><image src="/images/left.png"  ></image></view>
 7         <view style="float:left;width:60%;">
 8         <label class="progress-view">进度{{currentTime}}/{{duration}}</label>
 9          <progress class="progress" percent="{{currentTime/duration * 100}}" color="#F9F9FF" backgroundColor="#943134"></progress></view>
10         <view class="right-view" bindtap="NextPage" ><image src="/images/right.png"  ></image></view>
11     </view>
12 </view>

wxss:

  1 .container {
  2   /* height: 100%; */
  3   overflow: hidden;
  4 
  5 }
  6 
  7 page {
  8   /* height: 100%; */
  9   overflow: hidden;
 10   background-color: black;
 11   background: -moz-linear-gradient(top, #FE7676 0%, #FE4E4E 100%);
 12   background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #FE4E4E), color-stop(100%, #FE4E4E));
 13   background: -webkit-linear-gradient(top, #FE7676 0%, #FE4E4E 100%);
 14   background: -o-linear-gradient(top, #FE7676 0%, #FE4E4E 100%);
 15   background: -ms-linear-gradient(top, #FE7676 0%, #FE4E4E 100%);
 16   background: linear-gradient(to bottom, #FE7676 0%, #FE4E4E 100%);
 17 }
 18 
 19 .card {
 20   width: 600rpx;
 21   height: 800rpx;
 22   box-sizing: border-box;
 23   background-color: white;
 24   text-align: center;
 25   box-shadow: 2px 2px 8px #aaa;
 26   border-radius: 10rpx;
 27   padding: 0 50rpx;
 28   background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASsAAAGcCAYAAACBa4Z5AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABxDSURBVHhe7Z2JduK6tkXr/z/wvtufc6tLdTnVJ7Th7SVbIMS2sTEEdtWcY6xB6IxtrBlpI8yLDQBAAJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFACJAVAIQAWQFAC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NBJVMyQ9jc3m/wGqLRJFkaC9eAAAAABJRU5ErkJggg==');
 29   background-position: bottom;
 30 
 31 }
 32 
 33 .card .name {
 34   font-size: 20px;
 35   font-weight: bolder;
 36   margin: 60rpx 0 20rpx;
 37 }
 38 
 39 .card .location {
 40   font-size: 28rpx;
 41   margin: 30rpx 0 20rpx;
 42   line-height: 40rpx;
 43   text-align: left;
 44   color: #535353;
 45 
 46 }
 47 
 48 .name1 {
 49   font-size: 26rpx;
 50   font-weight: bolder;
 51 }
 52 
 53 .card .like-img {
 54   width: 50%;
 55   height: 45rpx;
 56   margin: 10rpx 0 40rpx;
 57 }
 58 
 59 .school-sign-img {
 60   width: 280rpx;
 61   height: 440rpx;
 62   position: absolute;
 63   left: 320rpx;
 64   top: 360rpx;
 65 }
 66 
 67 .allLikeView {
 68   width: 100rpx;
 69   height: 100rpx;
 70   box-sizing: border-box;
 71   background-color: white;
 72   padding: 30rpx;
 73   box-shadow: 0px 2px 8px #aaa;
 74   border-radius: 50rpx;
 75   margin: 800rpx;
 76 }
 77 
 78 .allLikeView .all-like-img {
 79   width: 40rpx;
 80   height: 40rpx;
 81 }
 82 
 83 .left-view {
 84   float: left;
 85   width: 20%;
 86   text-align: center;
 87   padding-top: 12rpx;
 88 }
 89 
 90 .left-view image {
 91   width: 32px;
 92   height: 32px;
 93 }
 94 
 95 .right-view {
 96   float: right;
 97   width: 20%;
 98   text-align: center;
 99   padding-top: 12rpx;
100 }
101 
102 .right-view image {
103   width: 32px;
104   height: 32px;
105 }
106 
107 .progress-view {
108   color: #ffffff;
109   text-align: center;
110   width: 100%;
111   font-size: 24rpx;
112   display: block;
113   padding-bottom: 12rpx;
114 }
View Code

js:

  1 import util from '../../utils/util.js';
  2 const marginHori = 74
  3 const marginVerti = 100
  4 
  5 Page({
  6 
  7   data: {
  8     course_id: 0,
  9     course_type: 1,
 10     info: [],
 11     currentTime: 0, //当前卡片的索引
 12     duration: 1, //持续时间,卡片总数;
 13 
 14     startX: 0, //滑动开始x轴
 15     startY: 0, //滑动开始y轴
 16 
 17     windowWidth: 0, //屏幕宽度
 18     windowHeight: 0, //屏幕高度
 19 
 20     currentId: 1,
 21   },
 22 
 23   onLoad: function (options) {
 24 
 25     wx.setNavigationBarTitle({
 26       title: '卡片动画',
 27     })
 28     var that = this
 29 
 30     //获取屏幕的宽度和高度
 31     wx.getSystemInfo({
 32       success: function (res) {
 33         that.setData({
 34           windowWidth: res.windowWidth,
 35           windowHeight: res.windowHeight
 36         })
 37       }
 38     });
 39 
 40     var course_id = options.id; //课程id
 41     var course_type = options.type; //课程类型
 42     this.setData({
 43       course_id: parseInt(course_id),
 44       course_type: parseInt(course_type),
 45     });
 46 
 47     //服务接口数据
 48     this.getInfo();
 49 
 50   },
 51   getInfo: function () {
 52     let self = this;
 53     util.request(util.apiUrl + '接口获取数据列表', 'POST', {
 54       course_id: self.data.course_id,
 55       course_type: self.data.course_type,
 56       currentTime: self.data.currentTime,
 57     }).then(res => {
 58       //
 59     }).catch(res => {
 60       var info = res.data.list;
 61 
 62       //获取服务器数据
 63       info.data.forEach((item, index) => {
 64         // info.data[index].animation = animation; //保存动画
 65         info.data[index].left = marginHori //卡片坐标 距左边距离
 66         info.data[index].top = marginVerti //卡片坐标 距上边距离
 67         if ((parseInt(info.currentTime) - 1) > index) { //数组索引index从0开始,所以需要-1
 68           info.data[index].left = 10000; //卡片坐标 距左边距离
 69           info.data[index].top = 10000; //卡片坐标 距上边距离
 70         }
 71       });
 72 
 73       self.setData({ //保存卡片数据
 74         info: info.data
 75       })
 76 
 77       self.setData({
 78         currentTime: info.currentTime,
 79         duration: parseInt(info.duration),
 80       });
 81       console.log(self.data.info);
 82     });
 83   },
 84 
 85   //获取课程进度
 86   getProcess: function () {
 87     let self = this;
 88     util.request(util.apiUrl + '接口', 'POST', {
 89       course_id: self.data.course_id, //当前课程id
 90       current: self.data.currentTime, //已看的索引
 91       duration: self.data.duration, //课程总共的卡片数量
 92       read_id: self.data.currentId, //当前索引
 93     }).then(res => {
 94       //
 95     }).catch(res => {
 96       console.log(res)
 97     });
 98   },
 99 
100   onReady: function () { },
101 
102   onShow: function () { },
103 
104   //手指触摸动作开始
105   viewTouchInside: function (event) {
106 
107     var that = this
108     var index = event.currentTarget.dataset.index; //下标
109     var item = that.data.info[index].animation; //获取每一个的动画
110     var pointX = event.touches[0].clientX
111     var pointY = event.touches[0].clientY
112 
113     that.setData({
114       startX: pointX,
115       startY: pointY,
116       currentId: event.currentTarget.id
117     })
118   },
119 
120   //手指触摸后移动
121   viewDidMove: function (event) {
122 
123     var that = this
124 
125     var pointX = event.touches[0].clientX
126     var pointY = event.touches[0].clientY
127 
128     var widthCenter = that.data.windowWidth / 2
129     var heightCenter = that.data.windowHeight / 2
130 
131     var perX = (pointX - that.data.startX) / widthCenter
132     var perY = (pointY - that.data.startY) / heightCenter
133     var maxPer = (Math.abs(perX) > Math.abs(perY)) ? Math.abs(perX) : Math.abs(perY)
134 
135     var index = event.currentTarget.dataset.index; //下标
136     var item = that.data.info[index].animation; //获取每一个的动画
137 
138     var animationRotate = wx.createAnimation({
139       duration: 100,
140       timingFunction: 'ease-out',
141     })
142     animationRotate.scale(1).rotate(perX * 20).step();
143     var x = marginHori + pointX - that.data.startX
144     var y = marginVerti + pointY - that.data.startY
145 
146     that.data.info[index].left = x,
147       that.data.info[index].top = y,
148       that.data.info[index].animation = animationRotate.export();
149 
150     that.setData({
151       info: that.data.info
152     })
153   },
154 
155   //手指触摸动作结束
156   viewTouchUpDownInside: function (event) {
157 
158     var that = this
159     console.log("that.data.currentId " + that.data.currentId);
160     var endX = event.changedTouches[0].clientX
161     var endY = event.changedTouches[0].clientY
162 
163     var distanceX = endX - that.data.startX
164     var distanceY = endY - that.data.startY
165 
166     var index = event.currentTarget.dataset.index; //下标 这个下标从0开始,所以不需要-1
167     var item = that.data.info[index].animation; //获取每一个的动画
168 
169     if (distanceX > 93.75) {
170       that.removeCard('right', index + 1); //往右移除卡片
171     } else if (distanceX < -93.75) {
172       that.removeCard('left', index + 1); //往左移除卡片
173     } else if (distanceY < -100) {
174       that.removeCard('up', index + 1); //往上移除卡片
175     } else if (distanceY > 100) {
176       that.removeCard('down', index + 1); //往下移除卡片
177     }
178 
179     var animation = wx.createAnimation({
180       duration: 100,
181       timingFunction: 'ease-out',
182     })
183 
184     //移动的范围不大,回到原点
185     if (distanceX < 93.75 && distanceX > -93.75 && distanceY > -150 && distanceY < 150) {
186 
187       that.data.info[index].left = marginHori;
188       that.data.info[index].top = marginVerti;
189       that.setData({
190         info: that.data.info
191       })
192       animation.scale(1).step();
193       that.data.info[index].animation = animation.export();
194       that.setData({ //保存动画内容并渲染到页面
195         info: that.data.info
196       })
197     }
198 
199   },
200 
201   //移除卡片
202   removeCard: function (direction, index) {
203 
204     console.log('removeCard', direction);
205     var that = this
206 
207     var animation = wx.createAnimation({
208       duration: 250,
209       timingFunction: 'linear',
210     })
211 
212     if (direction == 'right') { //往右滑动
213       animation.translateX(400).rotate(10).opacity(0).step()
214       animation.translateX(0).rotate(0).step()
215     } else if (direction == 'left') { //往左滑动
216       animation.translateX(-400).rotate(-45).opacity(0).step()
217       animation.translateX(0).rotate(0).step()
218     } else if (direction == 'up') { //往上滑动
219       animation.translateY(-400).opacity(0).step()
220       animation.translateY(0).step()
221     } else if (direction == 'down') { //往下滑动
222       animation.translateY(-60).opacity(0).step()
223       animation.translateY(0).opacity(1).rotate(0).step()
224     }
225 
226 
227     if (direction == 'down') { //下拉
228 
229       //index有可能为1
230       if (index > 1) {
231         that.data.info[index - 1 - 1].animation = animation.export(); //下一页,即将移除的卡片动画
232       }
233       that.setData({
234         info: that.data.info,
235       })
236       //
                      

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
幻方(附加生成五十阶以内幻方小程序)发布时间:2022-07-18
下一篇:
微信小程序-替换tabbar(采用固定定位形式)发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap