[微信小程序]动画,从顶部掉花的效果(完整代码附效果图)
2017-11-24 10:58
776 查看
image{ width: 100rpx; height: 100rpx; position: absolute; top: -100rpx; }
<!-- 动画 -->
<block wx:if="{{donghua}}">
<view class='donghua'>
<image bindtap='hua' style='left:{{left1}}px' animation="{{animationData1}}" class='love' src='../../image/hua2.png'></image>
<image bindtap='hua' style='left:{{left2}}px' animation="{{animationData2}}" class='love' src='../../image/hua2.png'></image>
<image bindtap='hua' style='left:{{left3}}px' animation="{{animationData3}}" class='love' src='../../image/hua2.png'></image>
<image bindtap='hua' style='left:{{left4}}px' animation="{{animationData4}}" class='love' src='../../image/hua2.png'></image>
<image bindtap='hua' style='left:{{left5}}px' animation="{{animationData5}}" class='love' src='../../image/hua2.png'></image>
<image bindtap='hua' style='left:{{left6}}px' animation="{{animationData6}}" class='love' src='../../image/hua2.png'></image>
</view>
</block>
var animation = wx.createAnimation({}) var i = 1; Page({ data: { donghua: true, left1: Math.floor(Math.random() * 305 + 1), left2: Math.floor(Math.random() * 305 + 1), left3: Math.floor(Math.random() * 305 + 1), left4: Math.floor(Math.random() * 305 + 1), left5: Math.floor(Math.random() * 305 + 1), left6: Math.floor(Math.random() * 305 + 1), }, onShow: function () { this.donghua() }, donghua: function () { setTimeout(function () { animation.translateY(604).step({ duration: 4000 }) this.setData({ ["animationData" + i]: animation.export() }) i++; }.bind(this), 500) if (i < 7) { setTimeout(function () { this.donghua() }.bind(this), 500) } else { console.log(22) setTimeout(function () { this.setData({ donghua: false }) }.bind(this), 4500) } } })
相关文章推荐
- [微信小程序]手指触摸动画效果(完整代码附效果图)
- 微信小程序实现跑马灯效果完整代码(附效果图)
- 微信小程序 跑马灯效果完整代码附效果图
- [微信小程序]物流信息样式加动画效果(源代码附效果图)
- 【微信小程序】侧滑栏,手动侧滑出个人中心(完整代码附效果图)
- 微信小程序有旋转动画效果的音乐组件实例代码
- [微信小程序]组件化开发,以一个自定义模块框组件当做示例(附完整示例代码和效果图)
- 微信小程序服务器请求和上传数据,上传图片并展示,提交表单完整实例代码附效果图
- [微信小程序]实现一个自定义遮罩层组件(完整示例代码附效果图)
- [微信小程序]聊天对话(文本,图片)的功能(完整代码附效果图)
- [微信小程序]组件化开发,以一个自定义模块框组件当做示例(附完整示例代码和效果图)
- [微信小程序]转发(分享)和打电话功能,完整代码附效果图
- 微信小程序 --- 6行代码实现页面返回顶部
- 微信小程序的动画效果详解
- Android仿打开微信红包动画效果实现代码
- 微信小程序左滑删除效果的实现代码
- Visual C# 2005 - 利用程序代码制作简单动画效果
- 微信小程序特殊效果合集—左滑、气泡各种酷炫动画
- jQuery实现带有动画效果的回到顶部和底部代码
- 微信小程序实现登录页云层漂浮的动画效果