轻源码

  • QingYuanMa.com
  • 全球最大的互联网技术和资源下载平台
搜索
一起源码网 门户 微信小程序 查看主题

微信小程序开发之『弹出菜单』特效

发布者: aiqing | 发布时间: 2018-6-13 07:20| 查看数: 4887| 评论数: 1|帖子模式

作者:ruicoding,来自原文地址 
先看下效果图. 

代码: 
1.popMenu.js

  1. Page({
  2. data: {
  3. isPopping: false,//是否已经弹出
  4. animPlus: {},//旋转动画
  5. animCollect: {},//item位移,透明度
  6. animTranspond: {},//item位移,透明度
  7. animInput: {},//item位移,透明度
  8. },
  9. //点击弹出
  10. plus: function () {
  11. if (this.data.isPopping) {
  12. //缩回动画
  13. this.popp();
  14. this.setData({
  15. isPopping: false
  16. })
  17. } else if (!this.data.isPopping) {
  18. //弹出动画
  19. this.takeback();
  20. this.setData({
  21. isPopping: true
  22. })
  23. }
  24. },
  25. input: function () {
  26. console.log("input")
  27. },
  28. transpond: function () {
  29. console.log("transpond")
  30. },
  31. collect: function () {
  32. console.log("collect")
  33. },
  34. //弹出动画
  35. popp: function () {
  36. //plus顺时针旋转
  37. var animationPlus = wx.createAnimation({
  38. duration: 500,
  39. timingFunction: 'ease-out'
  40. })
  41. var animationcollect = wx.createAnimation({
  42. duration: 500,
  43. timingFunction: 'ease-out'
  44. })
  45. var animationTranspond = wx.createAnimation({
  46. duration: 500,
  47. timingFunction: 'ease-out'
  48. })
  49. var animationInput = wx.createAnimation({
  50. duration: 500,
  51. timingFunction: 'ease-out'
  52. })
  53. animationPlus.rotateZ(180).step();
  54. animationcollect.translate(-100, -100).rotateZ(180).opacity(1).step();
  55. animationTranspond.translate(-140, 0).rotateZ(180).opacity(1).step();
  56. animationInput.translate(-100, 100).rotateZ(180).opacity(1).step();
  57. this.setData({
  58. animPlus: animationPlus.export(),
  59. animCollect: animationcollect.export(),
  60. animTranspond: animationTranspond.export(),
  61. animInput: animationInput.export(),
  62. })
  63. },
  64. //收回动画
  65. takeback: function () {
  66. //plus逆时针旋转
  67. var animationPlus = wx.createAnimation({
  68. duration: 500,
  69. timingFunction: 'ease-out'
  70. })
  71. var animationcollect = wx.createAnimation({
  72. duration: 500,
  73. timingFunction: 'ease-out'
  74. })
  75. var animationTranspond = wx.createAnimation({
  76. duration: 500,
  77. timingFunction: 'ease-out'
  78. })
  79. var animationInput = wx.createAnimation({
  80. duration: 500,
  81. timingFunction: 'ease-out'
  82. })
  83. animationPlus.rotateZ(0).step();
  84. animationcollect.translate(0, 0).rotateZ(0).opacity(0).step();
  85. animationTranspond.translate(0, 0).rotateZ(0).opacity(0).step();
  86. animationInput.translate(0, 0).rotateZ(0).opacity(0).step();
  87. this.setData({
  88. animPlus: animationPlus.export(),
  89. animCollect: animationcollect.export(),
  90. animTranspond: animationTranspond.export(),
  91. animInput: animationInput.export(),
  92. })
  93. },
  94. onLoad: function (options) {
  95. // 生命周期函数--监听页面加载
  96. },
  97. onReady: function () {
  98. // 生命周期函数--监听页面初次渲染完成
  99. },
  100. onShow: function () {
  101. // 生命周期函数--监听页面显示
  102. },
  103. onHide: function () {
  104. // 生命周期函数--监听页面隐藏
  105. },
  106. onUnload: function () {
  107. // 生命周期函数--监听页面卸载
  108. },
  109. onPullDownRefresh: function () {
  110. // 页面相关事件处理函数--监听用户下拉动作
  111. },
  112. onReachBottom: function () {
  113. // 页面上拉触底事件的处理函数
  114. },
  115. onShareAppMessage: function () {
  116. // 用户点击右上角分享
  117. return {
  118. title: 'title', // 分享标题
  119. desc: 'desc', // 分享描述
  120. path: 'path' // 分享路径
  121. }
  122. }
  123. })

2.popMenu.wxml

  1. <view>
  2. <image src="/pages/images/collect.png" class="img-style" animation="{{animCollect}}" bindtap="collect"></image>
  3. <image src="/pages/images/transpond.png" class="img-style" animation="{{animTranspond}}" bindtap="transpond"></image>
  4. <image src="/pages/images/input.png" class="img-style" animation="{{animInput}}" bindtap="input"></image>
  5. <image src="/pages/images/plus.png" class="img-plus-style" animation="{{animPlus}}" bindtap="plus"></image>
  6. </view>

3.popMenu.wxss

  1. .img-plus-style {
  2. height: 150rpx;
  3. width: 150rpx;
  4. position: absolute;
  5. bottom: 250rpx;
  6. right: 100rpx;
  7. z-index: 100;
  8. }
  9. .img-style {
  10. height: 150rpx;
  11. width: 150rpx;
  12. position: absolute;
  13. bottom: 250rpx;
  14. right: 100rpx;
  15. opacity: 0;
  16. }

最新评论

不知道叫啥好呀 发表于 2022-6-25 21:45
怎么用源代码下载歌曲

轻源码让程序更轻更快

QingYuanMa.com

工作时间 周一至周六 8:00-17:30

侵权处理

客服QQ点击咨询

关注抖音号

定期抽VIP

Copyright © 2016-2021 https://www.171739.xyz/ 滇ICP备13200218号

快速回复 返回顶部 返回列表