微信小程序实现弹出菜单动画


Posted in Javascript onJune 21, 2019

微信小程序动画之弹出菜单,供大家参考,具体内容如下

效果图

微信小程序实现弹出菜单动画

js:

Page({
 data: {
  isPopping: false,
  animPlus: {},
  animCollect: {},
  animTranspond: {},
  animInput: {},
  animCloud:{},
  aninWrite:{},
 },
 //点击弹出
 plus: function () {
  if (this.data.isPopping) {
   //缩回动画
   this.popp();
   this.setData({
    isPopping: false
   })
  } else if (!this.data.isPopping) {
   //弹出动画
   this.takeback();
   this.setData({
    isPopping: true
   })
  }
 },
 input: function () {
  console.log("input")
 },
 transpond: function () {
  console.log("transpond")
 },
 collect: function () {
  console.log("collect")
 },
 cloud:function(){
  console.log("cloud")
 },
 write: function () {
  console.log("cloud")
 },


 //弹出动画
 popp: function () {
  //plus顺时针旋转
  var animationPlus = wx.createAnimation({
   duration: 400,
   timingFunction: 'ease-out'
  })
  var animationcollect = wx.createAnimation({
   duration: 400,
   timingFunction: 'ease-out'
  })
  var animationTranspond = wx.createAnimation({
   duration: 400,
   timingFunction: 'ease-out'
  })
  var animationInput = wx.createAnimation({
   duration: 400,
   timingFunction: 'ease-out'
  })
  var animationCloud = wx.createAnimation({
   duration: 400,
   timingFunction: 'ease-out'
  })
  var animationWrite = wx.createAnimation({
   duration: 400,
   timingFunction: 'ease-out'
  })
  animationPlus.rotateZ(180).step();
  animationcollect.translate(-90, -100).rotateZ(180).opacity(1).step();
  animationTranspond.translate(-140, 0).rotateZ(180).opacity(1).step();
  animationInput.translate(-90, 100).rotateZ(180).opacity(1).step();
  animationCloud.translate(0, 135).rotateZ(180).opacity(1).step();
  animationWrite.translate(0, -135).rotateZ(180).opacity(1).step();
  this.setData({
   animPlus: animationPlus.export(),
   animCollect: animationcollect.export(),
   animTranspond: animationTranspond.export(),
   animInput: animationInput.export(),
   animCloud: animationCloud.export(),
   animWrite: animationWrite.export(),
  })
 },
 //收回动画
 takeback: function () {
  //plus逆时针旋转
  var animationPlus = wx.createAnimation({
   duration: 400,
   timingFunction: 'ease-out'
  })
  var animationcollect = wx.createAnimation({
   duration: 400,
   timingFunction: 'ease-out'
  })
  var animationTranspond = wx.createAnimation({
   duration: 400,
   timingFunction: 'ease-out'
  })
  var animationInput = wx.createAnimation({
   duration: 400,
   timingFunction: 'ease-out'
  })
  var animationCloud = wx.createAnimation({
   duration: 400,
   timingFunction: 'ease-out'
  })
  var animationWrite = wx.createAnimation({
   duration: 400,
   timingFunction: 'ease-out'
  })
  animationPlus.rotateZ(0).step();
  animationcollect.translate(0, 0).rotateZ(0).opacity(0).step();
  animationTranspond.translate(0, 0).rotateZ(0).opacity(0).step();
  animationInput.translate(0, 0).rotateZ(0).opacity(0).step();
  animationCloud.translate(0, 0).rotateZ(0).opacity(0).step();
  animationWrite.translate(0, 0).rotateZ(0).opacity(0).step();
  this.setData({
   animPlus: animationPlus.export(),
   animCollect: animationcollect.export(),
   animTranspond: animationTranspond.export(),
   animInput: animationInput.export(),
   animCloud: animationCloud.export(),
   animWrite: animationWrite.export(),
  })
 },


 onLoad: function (options) {
  // 生命周期函数--监听页面加载
 },
 onReady: function () {
  // 生命周期函数--监听页面初次渲染完成
 },
 onShow: function () {
  // 生命周期函数--监听页面显示
 },
 onHide: function () {
  // 生命周期函数--监听页面隐藏
 },
 onUnload: function () {
  // 生命周期函数--监听页面卸载
 },
 onPullDownRefresh: function () {
  // 页面相关事件处理函数--监听用户下拉动作
 },
 onReachBottom: function () {
  // 页面上拉触底事件的处理函数
 },
 onShareAppMessage: function () {
  // 用户点击右上角分享
  return {
   title: 'title', // 分享标题
   desc: 'desc', // 分享描述
   path: 'path' // 分享路径
  }
 }
})

wxml:

<view>
 <image src="../../image/1.png" class="img-style" animation="{{animWrite}}" bindtap="write"></image>
 <image src="../../image/4.png" class="img-style" animation="{{animCollect}}" bindtap="collect"></image>
 <image src="../../image/2.png" class="img-style" animation="{{animTranspond}}" bindtap="transpond"></image>
 <image src="../../image/3.png" class="img-style" animation="{{animInput}}" bindtap="input"></image>
 <image src="../../image/5.png" class="img-style" animation="{{animCloud}}" bindtap="cloud"></image>
 <image src="../../image/6.png" class="img-switch-style" animation="{{animPlus}}" bindtap="plus"></image>
</view>

wxss:

.img-switch-style {
 height: 120rpx;
 width: 120rpx;
 position: absolute;
 bottom: 250rpx;
 right: 100rpx;
 z-index: 100;
}
 
.img-style {
 height: 120rpx;
 width: 120rpx;
 position: absolute;
 bottom: 250rpx;
 right: 100rpx;
 opacity: 0;
}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持三水点靠木。

Javascript 相关文章推荐
用正则表达式 动态创建/增加css style script 兼容IE firefox
Mar 10 Javascript
8款非常棒的响应式jQuery 幻灯片插件推荐
Feb 02 Javascript
深入理解JSON数据源格式
Jan 10 Javascript
Visual Studio中js调试的方法图解
Jun 30 Javascript
javascript模拟post提交隐藏地址栏的参数
Sep 03 Javascript
JavaScript判断手机号运营商是移动、联通、电信还是其他(代码简单)
Sep 25 Javascript
JavaScript中动态向表格添加数据
Jan 24 Javascript
JS移动端/H5同时选择多张图片上传并使用canvas压缩图片
Jun 20 Javascript
微信小程序实现tab页面切换功能
Jul 13 Javascript
express express-session的使用小结
Dec 12 Javascript
解决Layui当中的导航条动态添加后渲染失败的问题
Sep 25 Javascript
vue调用语音播放的方法
Sep 27 Javascript
js类的继承定义与用法分析
Jun 21 #Javascript
js中值引用和地址引用实例分析
Jun 21 #Javascript
微信小程序实现消息框弹出动画
Apr 18 #Javascript
前端Electron新手入门教程详解
Jun 21 #Javascript
javascript实现自由编辑图片代码详解
Jun 21 #Javascript
JS中超越现实的匿名函数用法实例分析
Jun 21 #Javascript
微信小程序实现圆形进度条动画
Nov 18 #Javascript
You might like
phpBB BBcode处理的漏洞
2006/10/09 PHP
使用Appcan客户端自动更新PHP版本号(全)
2015/07/31 PHP
两个Javascript小tip资料
2010/11/23 Javascript
javascript数组遍历for与for in区别详解
2014/12/04 Javascript
JS简单实现城市二级联动选择插件的方法
2015/08/19 Javascript
js clearInterval()方法的定义和用法
2015/11/11 Javascript
Node.js+Express配置入门教程详解
2016/05/19 Javascript
ES6新特性之字符串的扩展实例分析
2017/04/01 Javascript
jQuery模拟实现天猫购物车动画效果实例代码
2017/05/25 jQuery
微信浏览器禁止页面下拉查看网址实例详解
2017/06/28 Javascript
详解JS中的柯里化(currying)
2017/08/17 Javascript
详解如何在vue项目中引入elementUI组件
2018/02/11 Javascript
js实现京东秒杀倒计时功能
2019/01/21 Javascript
Node.js fs模块(文件模块)创建、删除目录(文件)读取写入文件流的方法
2019/09/03 Javascript
js通过循环多张图片实现动画效果
2019/12/19 Javascript
[02:06]DOTA2肉山黑名单魔法终结者 敌法师中文配音鉴赏
2013/06/17 DOTA
[15:39]教你分分钟做大人:龙骑士
2014/10/30 DOTA
[01:11:21]DOTA2-DPC中国联赛 正赛 Phoenix vs CDEC BO3 第三场 3月7日
2021/03/11 DOTA
Python中用startswith()函数判断字符串开头的教程
2015/04/07 Python
Java实现的执行python脚本工具类示例【使用jython.jar】
2018/03/29 Python
在IPython中执行Python程序文件的示例
2018/11/01 Python
python 定时器,实现每天凌晨3点执行的方法
2019/02/20 Python
Python利用lxml模块爬取豆瓣读书排行榜的方法与分析
2019/04/15 Python
python区分不同数据类型的方法
2019/10/14 Python
Tensorflow训练模型越来越慢的2种解决方案
2020/02/07 Python
Yves Rocher捷克官方网站:植物化妆品的创造者
2019/07/31 全球购物
游戏商店:Eneba
2020/04/25 全球购物
师范生自荐信
2013/10/27 职场文书
外贸销售员求职的自我评价
2013/11/23 职场文书
客服专员岗位职责范本
2013/11/29 职场文书
大学生饮食配送创业计划书
2014/01/04 职场文书
路政管理毕业自荐书范文
2014/02/10 职场文书
大学生自我评价范文分享
2014/02/21 职场文书
2015年基层党组织公开承诺书
2015/01/21 职场文书
Python爬虫实战之爬取携程评论
2021/06/02 Python
Python Flask实现进度条
2022/05/11 Python