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

代码:

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. js中scroll滚动相关

    js中scroll滚动相关 scroll,滚动,一般讨论的是网页整体与浏览器之间的关系. 一.元素相关 属性/方法 解释 element.scrollHeight 返回元素的整体高度. element ...

  2. linux中rpm和yum

    一.rpm介绍 一种用于互联网下载包的打包及安装工具.它生成具有.RPM 扩展名的文件.RPM 是 RedHat Package Manager(RedHat 软件包管理工具)的缩写,类似 windo ...

  3. flex三个对齐属性的记忆方式

    今天在群里聊天有人说 flex的那几个居中属性好难记,时不时都要尝试一下,或者查看一下文档,现在我把我自己的记忆方式分享一下... 1. flex的居中主要是通过这三个属性来实现的: justify- ...

  4. HTML 本地存储

    HTML 本地存储:优于 cookies. 什么是 HTML 本地存储? 通过本地存储(Local Storage),web 应用程序能够在用户浏览器中对数据进行本地的存储. 在 HTML5 之前,应 ...

  5. 前vue.js+elementui,后koa2,nodejs搭建网站

    1,安装 nodejs,npm 2,使用 npm 安装 vue,vue-cli 3,使用脚手架搭建项目,添加依赖:axios,vue-router,elementui,vuex 等 4,建立 rout ...

  6. 1.1选择select

    一.核心(Core) 1.1选择 1.1.1 d3.select(selector) ​ 选择第一个与指定字符串selector匹配的元素,如果没有就返回空. 例如: <table> &l ...

  7. 利用Azure虚拟机安装Dynamics 365 Customer Engagement之七:安装前端服务器及部署管理器

    我是微软Dynamics 365 & Power Platform方面的工程师罗勇,也是2015年7月到2018年6月连续三年Dynamics CRM/Business Solutions方面 ...

  8. 算法复杂度O(logn)详解

    一.O(logn)代码小证明 我们先来看下面一段代码: int cnt = 1; while (cnt < n) { cnt *= 2; //时间复杂度为O(1)的程序步骤序列 } 由于cnt每 ...

  9. mock 模拟数据在框架中的简单使用

    首先在框架中需要安装mock模块 cnpm i mockjs -S 其次在src文件夹下新建mock文件夹,在mock文件夹中新建一个index.js文件 代码如下: const Mock = req ...

  10. nodejs+Express中使用mustache模板引擎

    由于公司一个seo项目,需要我协助.此项目他人已经开发大半,由于seo需要,使用了服务器端模板引擎.我项目的后端同事说项目是go语音写的,跑项目麻烦,只给了我template和css等静态文件. 为了 ...