用微信小程序做了一个动画,效果如上图:

代码:

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;
}

  

微信小程序动画之弹出菜单的更多相关文章

  1. 微信小程序组件 自定义弹出框

    <!-- 点击立即抢拼弹出框 --> <view class='add-rob' bindtap="setModalStatus" data-status=&qu ...

  2. 微信小程序日期定位弹出框遮挡问题

    只需要用bindtap绑定一个点击后的操作(隐藏键盘): wx.hideKeyboard()

  3. 微信小程序之底部弹框预约插件

    代码地址如下:http://www.demodashi.com/demo/13982.html 一.前期准备工作: 软件环境:微信开发者工具 官方下载地址:https://mp.weixin.qq.c ...

  4. 微信小程序动画:高度渐变,left渐变

    今天在测试微信小程序动画的时候遇到了坑,需求是这样的点击时子元素从外部滑动回来,父元素的高度跟随子元素的高度改变. 实现子元素left为0并不复杂,但是改变父元素box的高度的时候却遇到了坑,因为是需 ...

  5. 微信小程序开发视频教程新鲜出炉

    微信小程序开发公测了,可是对于新手来说,不同的框架不同的开发机制,如何快速适应呢?微信小程序开发视频教程新鲜出炉了,从零开始一步一步搭建微信小程序,每个章节都会涉及到不同的知识点,等教程学习完你不但掌 ...

  6. 微信小程序动画之圆形进度条

    微信小程序动画之圆形进度条 上图: js: //获取应用实例 var app = getApp() var interval; var varName; var ctx = wx.createCanv ...

  7. 微信小程序动画实现(API,css)

    微信小程序动画API实现 index.js clicktap:function(){ var Animation=wx.createAnimation({ duration: 2000, }) Ani ...

  8. win32进阶之路:程序托盘图标+右键弹出菜单

     开场白 本次介绍两个非常棒且实用的技巧:程序托盘图标和右键弹出菜单,效果如下图. 程序托盘图标用了迅雷的图标,右键点击时候会弹出三个选项的菜单. 程序托盘图标设置 我会用尽可能清晰明了的步骤介绍方式 ...

  9. 微信小程序如何自动弹出提示微信授权?

    我想在一进入页面的时候就进行判断提示并且弹出提示授权!请问该如何处理比较合理 wx.authorize({}) //可以通过 wx.getSetting 先查询一下用户是否授权了 "scop ...

随机推荐

  1. pecl安装和卸载示例

    比如安装MongoDB扩展 命令行下输入: [#] /usr/local/php/bin/pecl install mongodb ......嗒吧嗒吧一大堆输出后 Build process com ...

  2. SSH框架之Struts2第二篇

    1.2 知识点 1.2.1 Struts2的Servlet的API的访问 1.2.1.1 方式一 : 通过ActionContext实现 页面: <h1>Servlet的API的访问方式一 ...

  3. SQLServer之GROUP BY语句

    GROUP BY 语句 GROUP BY 语句用于结合合计函数,根据一个或多个列对结果集进行分组. SQL GROUP BY 语法 SELECT column_name, aggregate_func ...

  4. flutter全栈开发学习资料大全 免费flutter学习视频 文字教程!

    flutter今年特别火,google推出flutter就是为了一次开发全平台应用,包括PC端,手机wap端,android,ios直接生成APP应用,如果真的能像谷歌说的,那我们开发人员就真的好好学 ...

  5. 通过Shell脚本来创建批量服务器上的MySQL数据库账号

    1.项目背景 因监控需要,我们需要在既有的每个MySQL实例上创建一个账号.公司有数百台 MySQL 实例,如果手动登入来创建账号很麻烦,也不现实.所以,我们写了一个简单的shell脚本,用来创建批量 ...

  6. python while语句

    一.while 1.while 死循环 f=True while f: print(1) print(2) 2.while 活循环 ①.正序 count = 1 while count <= 5 ...

  7. python redis的连接及相关操作

    1.redis连接.及存取值 import redis r = redis.Redis(host='192.168.2.22',port=6379,db=2,password= 'redis') r. ...

  8. 201871010116-祁英红《面向对象程序设计(java)》第十二周学习总结

    博文正文开头格式:(2分) 项目 内容 <面向对象程序设计(java)> https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://ww ...

  9. 166. 数独 dancing links 方法

    dfs硬怼通过数独 N皇后的代码后 想学习下新的数据结构和算法来解决这类覆盖问题 习题练习 https://www.acwing.com/problem/content/168/ 数独 https:/ ...

  10. 剑指Offer-28.数组中出现次数超过一半的数字(C++/Java)

    题目: 数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字.例如输入一个长度为9的数组{1,2,3,2,2,2,5,4,2}.由于数字2在数组中出现了5次,超过数组长度的一半,因此输出2.如 ...