微信小程序实现弹出菜单


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 相关文章推荐
自动检查并替换文本框内的字符
Jun 30 Javascript
prototype Element学习笔记(Element篇三)
Oct 26 Javascript
面向对象Javascript核心支持代码分享
May 23 Javascript
JS实现定时页面弹出类似QQ新闻的提示框
Nov 07 Javascript
jQuery(js)获取文字宽度(显示长度)示例代码
Dec 31 Javascript
jQuery预加载图片常用方法
Jun 15 Javascript
jquery实现Ctrl+Enter提交表单的方法
Jul 21 Javascript
JS实现新浪微博效果带遮罩层的弹出框代码
Oct 12 Javascript
bootstrap布局中input输入框右侧图标点击功能
May 16 Javascript
vue.js使用代理和使用Nginx来解决跨域的问题
Feb 03 Javascript
微信小程序动态生成二维码的实现代码
Jul 25 Javascript
vue实现动态列表点击各行换色的方法
Sep 13 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
PHP $_FILES中error返回值详解
2014/01/30 PHP
Laravel路由研究之domain解决多域名问题的方法示例
2019/04/04 PHP
在phpstudy集成环境下的nginx服务器下配置url重写
2019/12/02 PHP
js批量设置样式的三种方法不推荐使用with
2013/02/25 Javascript
Javascript学习笔记之数组的构造函数
2014/11/23 Javascript
DOM基础教程之使用DOM + Css
2015/01/20 Javascript
HTML5+Canvas调用手机拍照功能实现图片上传(下)
2017/04/21 Javascript
详解react使用react-bootstrap当轮子造车
2017/08/15 Javascript
使用clipboard.js实现复制功能的示例代码
2017/10/16 Javascript
使用3D引擎threeJS实现星空粒子移动效果
2020/09/13 Javascript
vue+koa2实现session、token登陆状态验证的示例
2019/08/30 Javascript
JS获取表格视图所选行号的ids过程解析
2020/02/21 Javascript
Python数据类型学习笔记
2016/01/13 Python
python bottle框架支持jquery ajax的RESTful风格的PUT和DELETE方法
2017/05/24 Python
Python操作Redis之设置key的过期时间实例代码
2018/01/25 Python
Python之——生成动态路由轨迹图的实例
2019/11/22 Python
python队列原理及实现方法示例
2019/11/27 Python
Python3中的f-Strings增强版字符串格式化方法
2020/03/04 Python
浅谈Python中range与Numpy中arange的比较
2020/03/11 Python
Python之变量类型和if判断方式
2020/05/05 Python
python 爬虫请求模块requests详解
2020/12/04 Python
表单button的outline在firefox浏览器下的问题
2012/12/24 HTML / CSS
HTML5实现的图片无限加载的瀑布流效果另带边框圆角阴影
2014/03/07 HTML / CSS
HTML5仿微信聊天界面、微信朋友圈实例代码
2018/01/29 HTML / CSS
高中考试作弊检讨书
2014/01/14 职场文书
学校校庆演讲稿
2014/05/22 职场文书
团队精神口号
2014/06/06 职场文书
日语专业毕业生自荐书
2014/06/18 职场文书
2014年社区居委会主任重阳节讲话稿
2014/09/25 职场文书
先进基层党组织事迹材料
2014/12/25 职场文书
教师考核评语大全
2014/12/31 职场文书
技术员岗位职责
2015/02/04 职场文书
办公室主任个人总结
2015/02/28 职场文书
2016年“世界环境日”校园广播稿
2015/12/18 职场文书
如何写好活动总结
2019/06/21 职场文书
python使用pywinauto驱动微信客户端实现公众号爬虫
2021/05/19 Python