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


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 相关文章推荐
AJAX的跨域与JSONP(为文章自动添加短址的功能)
Jan 17 Javascript
js鼠标及对象坐标控制属性详细解析
Dec 14 Javascript
使用jquery动态加载Js文件和Css文件
Oct 24 Javascript
AngularJS  自定义指令详解及实例代码
Sep 14 Javascript
正则验证小数点后面只能有两位数的方法
Feb 28 Javascript
DVA框架统一处理所有页面的loading状态
Aug 25 Javascript
vue.js实现只弹一次弹框
Jan 29 Javascript
原生JS+HTML5实现跟随鼠标一起流动的粒子动画效果
May 03 Javascript
Vue中 v-if/v-show/插值表达式导致闪现的原因及解决办法
Oct 12 Javascript
mpvue开发音频类小程序踩坑和建议详解
Mar 12 Javascript
微信小程序自定义弹窗滚动与页面滚动冲突的解决方法
Jul 16 Javascript
如何对react hooks进行单元测试的方法
Aug 14 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
php file_put_contents()功能函数(集成了fopen、fwrite、fclose)
2011/05/24 PHP
PHP操作文件类的函数代码(文件和文件夹创建,复制,移动和删除)
2011/11/10 PHP
详解php中serialize()和unserialize()函数
2017/07/08 PHP
PHP实现一个限制实例化次数的类示例
2019/09/16 PHP
破除网页鼠标右键被禁用的绝招大全
2006/12/27 Javascript
js或css文件后面跟参数的原因说明
2010/01/09 Javascript
js 禁用只读文本框获得焦点时的退格键
2010/04/25 Javascript
js阻止事件追加的具体实现
2014/10/15 Javascript
js实现类似jquery里animate动画效果的方法
2015/04/10 Javascript
javascript动画算法实例分析
2015/07/31 Javascript
jQuery获取DOM节点实例分析(2种方式)
2015/12/15 Javascript
jQuery:unbind方法的使用详解
2017/08/14 jQuery
vue2.0移动端滑动事件vue-touch的实例代码
2018/11/27 Javascript
Vue-cli项目部署到Nginx服务器的方法
2019/11/01 Javascript
[01:02]2014 DOTA2国际邀请赛中国区预选赛 现场抢先看
2014/05/22 DOTA
把项目从Python2.x移植到Python3.x的经验总结
2015/04/20 Python
python判断一个集合是否包含了另外一个集合中所有项的方法
2015/06/30 Python
Python网络爬虫神器PyQuery的基本使用教程
2018/02/03 Python
pycharm运行出现ImportError:No module named的解决方法
2018/10/13 Python
Python调用服务接口的实例
2019/01/03 Python
python shell命令行中import多层目录下的模块操作
2020/03/09 Python
解决pyqt5异常退出无提示信息的问题
2020/04/08 Python
Python配置pip国内镜像源的实现
2020/08/20 Python
详解CSS3中@media的实际使用
2015/08/04 HTML / CSS
全球摩托车装备领导者:RevZilla
2017/09/04 全球购物
高级人员简历的自我评价分享
2013/11/03 职场文书
课程改革实施方案
2014/03/16 职场文书
校园演讲稿汇总
2014/05/21 职场文书
奥巴马当选演讲稿
2014/09/10 职场文书
执法作风整顿剖析材料
2014/10/11 职场文书
2014年信访工作总结
2014/11/17 职场文书
2014年科室工作总结范文
2014/12/19 职场文书
写给妈妈的感谢信
2015/01/22 职场文书
2019年大学生暑期社会实践调查报告模板
2019/11/07 职场文书
golang内置函数len的小技巧
2021/07/25 Golang
js判断两个数组相等的5种方法
2022/05/06 Javascript