微信小程序?qū)崿F(xiàn)彈出菜單動畫
更新時間:2019年06月21日 11:35:04 作者:CodeHunter_qcy
這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崿F(xiàn)彈出菜單動畫,具有一定的參考價值,感興趣的小伙伴們可以參考一下
微信小程序動畫之彈出菜單,供大家參考,具體內(nèi)容如下
效果圖

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順時針旋轉(zhuǎn)
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逆時針旋轉(zhuǎn)
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) {
// 生命周期函數(shù)--監(jiān)聽頁面加載
},
onReady: function () {
// 生命周期函數(shù)--監(jiān)聽頁面初次渲染完成
},
onShow: function () {
// 生命周期函數(shù)--監(jiān)聽頁面顯示
},
onHide: function () {
// 生命周期函數(shù)--監(jiān)聽頁面隱藏
},
onUnload: function () {
// 生命周期函數(shù)--監(jiān)聽頁面卸載
},
onPullDownRefresh: function () {
// 頁面相關(guān)事件處理函數(shù)--監(jiān)聽用戶下拉動作
},
onReachBottom: function () {
// 頁面上拉觸底事件的處理函數(shù)
},
onShareAppMessage: function () {
// 用戶點擊右上角分享
return {
title: 'title', // 分享標(biāo)題
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;
}
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
JavaScript中使用arguments獲得函數(shù)傳參個數(shù)實例
這篇文章主要介紹了JavaScript中使用arguments獲得函數(shù)傳參個數(shù)實例,本文用了多個例子來講解arguments的使用,需要的朋友可以參考下2014-08-08
uniapp使用uni.chooseLocation()打開地圖選擇位置詳解
這篇文章主要給大家介紹了關(guān)于uniapp使用uni.chooseLocation()打開地圖選擇位置的相關(guān)資料,因為最近在項目中遇到一個要用戶授權(quán)位置且可以用戶自己選擇位置的功能,需要的朋友可以參考下2023-06-06
微信小程序?qū)崿F(xiàn)頁面監(jiān)聽自定義組件的觸發(fā)事件
這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崿F(xiàn)頁面監(jiān)聽自定義組件的觸發(fā)事件,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2020-11-11
JavaScript使用ul中l(wèi)i標(biāo)簽實現(xiàn)刪除效果
這篇文章主要為大家詳細(xì)介紹了JavaScript使用ul中l(wèi)i標(biāo)簽實現(xiàn)刪除效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下2019-04-04

