国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 熱點 > 微信 > 正文

微信小程序實現炫酷的彈出式菜單特效

2024-07-22 01:19:08
字體:
來源:轉載
供稿:網友

今天給大家帶來一個微信小程序的彈出是菜單效果,老規矩先上效果圖。(錄制的gif動畫有點卡,實際真機或是模擬器上很順暢)

先簡單說下思路:

1、首先在屏幕的某個位置放幾個懸浮按鈕,放幾個看你需要的功能

2、點擊最上層(wxml中最后一個就是最上層)的的按鈕后增加背景遮罩,這個遮罩在我前面自定義modal彈框時有用到

3、分別對按鈕做旋轉和移動動畫和透明度,造成動畫差異就是位移的動畫距離不同

4、收起的時候回到原來位置并且讓透明度變成0就ok了

思路說完了,下面開始上實現代碼,這里同樣也是封裝成了組件,方便調用。

首先是wxml實現

<view class="drawer_screen" bindtap="showOrHide" wx:if="{{isShow}}" catchtouchmove="myCatchTouch"></view><view > <image src="../../img/add.png" class="buttom" animation="{{animDelLots}}" bindtap="deleteLots"></image> <image src="../../img/add.png" class="buttom" animation="{{animAdd}}" bindtap="add"></image> <image src="../../img/add.png" class="buttom" animation="{{animMain}}" bindtap="showOrHide"></image></view>

然后是wxss

//懸浮按鈕.buttom{ width: 100rpx; height: 100rpx; display: flex; flex-direction: row; position: fixed; bottom:60rpx; right: 60rpx; z-index: 1001;}.drawer_screen { width: 100%; height: 100%; position: fixed; top: 0; left: 0; right:0; bottom:0; z-index: 1000; background: #000; opacity: 0.5; overflow: hidden;}.drawer_box { overflow: hidden; position: fixed; z-index: 1001;}

json文件

{ "component": true, "usingComponents": {}}

最后是js邏輯實現

// components/Menu/menu.jsvar systemInfo = wx.getSystemInfoSync();Component({ /** * 組件的屬性列表 */ properties: {  },  /** * 組件的初始數據 */ data: { isShow: false,//是否已經彈出 animMain: {},//旋轉動畫 animAdd: {},//item位移,透明度 animDelLots: {},//item位移,透明度 },  /** * 組件的方法列表 */ methods: { //點擊彈出或者收起 showOrHide: function () {  if (this.data.isShow) {  //縮回動畫  this.takeback();  this.setData({   isShow: false  })  } else {  //彈出動畫  this.popp();  this.setData({   isShow: true  })  } }, add: function () {  this.triggerEvent("addEvent")  this.showOrHide() }, deleteLots: function () {  this.triggerEvent("deleteLotsEvent")  this.showOrHide() },  //彈出動畫 popp: function () {  //main按鈕順時針旋轉  var animationMain = wx.createAnimation({  duration: 500,  timingFunction: 'ease-out'  })  var animationDelLots = wx.createAnimation({  duration: 500,  timingFunction: 'ease-out'  })  var animationAdd = wx.createAnimation({  duration: 500,  timingFunction: 'ease-out'  })  animationMain.rotateZ(180).step();  animationDelLots.translate(0, -200 / 750 * systemInfo.windowWidth).rotateZ(180).opacity(1).step();  animationAdd.translate(0, -320 / 750 * systemInfo.windowWidth).rotateZ(180).opacity(1).step();  this.setData({  animMain: animationMain.export(),  animDelLots: animationDelLots.export(),  animAdd: animationAdd.export(),  }) }, //收回動畫 takeback: function () {  //main按鈕逆時針旋轉  var animationMain = wx.createAnimation({  duration: 500,  timingFunction: 'ease-out'  })  var animationDelLots = wx.createAnimation({  duration: 500,  timingFunction: 'ease-out'  })  var animationAdd = wx.createAnimation({  duration: 500,  timingFunction: 'ease-out'  })  animationMain.rotateZ(0).step();  animationDelLots.translate(0, 0).rotateZ(0).opacity(0).step();  animationAdd.translate(0, 0).rotateZ(0).opacity(0).step();  this.setData({  animMain: animationMain.export(),  animDelLots: animationDelLots.export(),  animAdd: animationAdd.export(),  }) } }, //解決滾動穿透問題 myCatchTouch: function () { return }})            
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 南昌县| 屏东市| 西昌市| 浪卡子县| 柳州市| 邛崃市| 什邡市| 依兰县| 乳源| 蒙自县| 江阴市| 新建县| 朝阳区| 疏勒县| 大关县| 无棣县| 黄山市| 津南区| 敦化市| 二手房| 佳木斯市| 合川市| 江门市| 眉山市| 温州市| 南溪县| 海阳市| 珠海市| 镇雄县| 师宗县| 江源县| 康保县| 特克斯县| 合江县| 五大连池市| 本溪| 镇巴县| 读书| 龙游县| 姚安县| 乐东|