微信小程序实现弹出菜单


Posted in Javascript onJuly 19, 2018

本文实例为大家分享了微信小程序实现弹出菜单的具体代码,供大家参考,具体内容如下

菜单

微信小程序实现弹出菜单

代码:

1.index.js

//index.js
//获取应用实例
var app = getApp()
Page({
 data: {
 isPopping: false,//是否已经弹出
 animationPlus: {},//旋转动画
 animationcollect: {},//item位移,透明度
 animationTranspond: {},//item位移,透明度
 animationInput: {},//item位移,透明度
 //我的博客:http://blog.csdn.net/qq_31383345
 //CSDN微信小程序开发专栏:http://blog.csdn.net/column/details/13721.html
 },
 onLoad: function () {

 },
 //点击弹出
 plus: function () {
 if (this.data.isPopping) {
  //缩回动画
  popp.call(this);
  this.setData({
  isPopping: false
  })
 } else {
  //弹出动画
  takeback.call(this);
  this.setData({
  isPopping: true
  })
 }
 },
 input: function () {
 console.log("input")
 },
 transpond: function () {
 console.log("transpond")
 },
 collect: function () {
 console.log("collect")
 }
})



//弹出动画
function popp() {
 //plus顺时针旋转
 var animationPlus = wx.createAnimation({
 duration: 500,
 timingFunction: 'ease-out'
 })
 var animationcollect = wx.createAnimation({
 duration: 500,
 timingFunction: 'ease-out'
 })
 var animationTranspond = wx.createAnimation({
 duration: 500,
 timingFunction: 'ease-out'
 })
 var animationInput = wx.createAnimation({
 duration: 500,
 timingFunction: 'ease-out'
 })
 animationPlus.rotateZ(180).step();
 animationcollect.translate(-100, -100).rotateZ(180).opacity(1).step();
 animationTranspond.translate(-140, 0).rotateZ(180).opacity(1).step();
 animationInput.translate(-100, 100).rotateZ(180).opacity(1).step();
 this.setData({
 animationPlus: animationPlus.export(),
 animationcollect: animationcollect.export(),
 animationTranspond: animationTranspond.export(),
 animationInput: animationInput.export(),
 })
}
//收回动画
function takeback() {
 //plus逆时针旋转
 var animationPlus = wx.createAnimation({
 duration: 500,
 timingFunction: 'ease-out'
 })
 var animationcollect = wx.createAnimation({
 duration: 500,
 timingFunction: 'ease-out'
 })
 var animationTranspond = wx.createAnimation({
 duration: 500,
 timingFunction: 'ease-out'
 })
 var animationInput = wx.createAnimation({
 duration: 500,
 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();
 this.setData({
 animationPlus: animationPlus.export(),
 animationcollect: animationcollect.export(),
 animationTranspond: animationTranspond.export(),
 animationInput: animationInput.export(),
 })
}

2.index.wxml

<!--index.wxml-->
<image src="../../images/collect.png" animation="{{animationcollect}}" class="image-style" bindtap="collect"></image>
<image src="../../images/transpond.png" animation="{{animationTranspond}}" class="image-style" bindtap="transpond"></image>
<image src="../../images/input.png" animation="{{animationInput}}" class="image-style" bindtap="input"></image>
<image src="../../images/plus.png" animation="{{animationPlus}}" class="image-plus-style" bindtap="plus"></image>

3.index.wxss

/**index.wxss**/

.image-style {
 height: 150rpx;
 width: 150rpx;
 position: absolute;
 bottom: 250rpx;
 right: 100rpx;
 opacity: 0;
}

.image-plus-style {
 height: 150rpx;
 width: 150rpx;
 position: absolute;
 bottom: 250rpx;
 right: 100rpx;
 z-index: 100;
}

demo代码下载

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

Javascript 相关文章推荐
js验证表单大全
Nov 25 Javascript
js弹出模式对话框,并接收回传值的方法
Mar 12 Javascript
现代 JavaScript 开发编程风格Idiomatic.js指南中文版
May 28 Javascript
js实现缓冲运动效果的方法
Apr 10 Javascript
TypeError document.getElementById(...) is null错误原因
May 18 Javascript
React学习笔记之条件渲染(一)
Jul 02 Javascript
深入浅析Node.js单线程模型
Jul 10 Javascript
vue+iview写个弹框的示例代码
Dec 05 Javascript
vue指令之表单控件绑定v-model v-model与v-bind结合使用
Apr 17 Javascript
Node.js中Koa2在控制台输出请求日志的方法示例
May 02 Javascript
关于uniApp editor微信滑动问题
Jan 15 Javascript
AJAX学习笔记
May 18 Javascript
微信小程序实现之手势锁功能实例代码
Jul 19 #Javascript
React组件重构之嵌套+继承及高阶组件详解
Jul 19 #Javascript
微信小程序实现折叠展开效果
Jul 19 #Javascript
详解Angularjs 自定义指令中的数据绑定
Jul 19 #Javascript
微信小程序实现天气预报功能
Jul 18 #Javascript
vue代理和跨域问题的解决
Jul 18 #Javascript
小程序自定义组件实现城市选择功能
Jul 18 #Javascript
You might like
德生PL550的电路分析
2021/03/02 无线电
javascript 支持ie和firefox杰奇翻页函数
2008/07/22 Javascript
JSON.parse 解析字符串出错的解决方法
2010/07/08 Javascript
jquery nth-child()选择器的简单应用
2010/07/10 Javascript
JavaScript中链式调用之研习
2011/04/07 Javascript
javascript实现div浮动在网页最顶上并带关闭按钮效果实例
2013/08/13 Javascript
Jquery解析json数据详解
2013/12/26 Javascript
JS拖拽插件实现步骤
2015/08/03 Javascript
jQuery实现打开页面渐现效果示例
2016/07/27 Javascript
js+html制作简单日历的方法
2017/06/27 Javascript
vue.js或js实现中文A-Z排序的方法
2018/03/08 Javascript
微信小程序中时间戳和日期的相互转换问题
2018/07/09 Javascript
layui问题之模拟select点击事件的实例讲解
2018/08/15 Javascript
javascript实现自由编辑图片代码详解
2019/06/21 Javascript
js实现随机div颜色位置 类似满天星效果
2019/10/24 Javascript
vue实现弹幕功能
2019/10/25 Javascript
Python3 模块、包调用&amp;路径详解
2017/10/25 Python
python计算阶乘和的方法(1!+2!+3!+...+n!)
2019/02/01 Python
Python Numpy 实现交换两行和两列的方法
2019/06/26 Python
python输出决策树图形的例子
2019/08/09 Python
python对Excel的读取的示例代码
2020/02/14 Python
Python socket处理client连接过程解析
2020/03/18 Python
PyTorch的torch.cat用法
2020/06/28 Python
美国顶级户外凉鞋品牌:Chacos
2017/03/27 全球购物
护士自荐信怎么写
2013/10/18 职场文书
村官工作鉴定评语
2014/01/27 职场文书
就业意向书范文
2014/04/01 职场文书
实习生工作证明范本
2014/09/14 职场文书
2014年库房工作总结
2014/11/26 职场文书
2014年档案管理员工作总结
2014/12/01 职场文书
2015元旦节寄语
2014/12/08 职场文书
幼儿园圣诞节活动总结
2015/05/06 职场文书
2016年植树节红领巾广播稿
2015/12/17 职场文书
求职自荐信该如何书写?
2019/06/24 职场文书
Python OpenCV超详细讲解基本功能
2022/04/02 Python
python中validators库的使用方法详解
2022/09/23 Python