animationControl.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // #ifdef APP-PLUS
  2. const animation = weex.requireModule('animation')
  3. // #endif
  4. export default {
  5. methods: {
  6. /**
  7. * 显示面板
  8. */
  9. panelShow() {
  10. let that = this;
  11. let sys = uni.getSystemInfoSync();
  12. animation.transition(
  13. that.$refs.mask,
  14. {
  15. styles: {
  16. opacity: 1,
  17. height: sys.windowHeight + 'px'
  18. },
  19. duration: 200, //ms
  20. timingFunction: 'linear',
  21. delay: 0 //ms
  22. }
  23. )
  24. let height = Math.ceil(sys.windowHeight * 0.8);
  25. animation.transition(
  26. that.$refs.panel,
  27. {
  28. styles: {
  29. opacity: 1,
  30. transform: `transform: translate(0px,${height}px)`
  31. },
  32. duration: 1, //ms
  33. timingFunction: 'linear',
  34. delay: 0 //ms
  35. },
  36. (res) => {
  37. animation.transition(
  38. that.$refs.panel,
  39. {
  40. styles: {
  41. transform: `transform: translate(0px,0px)`
  42. },
  43. duration: 200, //ms
  44. timingFunction: 'linear',
  45. delay: 0 //ms
  46. }
  47. )
  48. }
  49. )
  50. },
  51. /**
  52. * 关闭面板
  53. */
  54. panelHide() {
  55. let that = this;
  56. animation.transition(
  57. that.$refs.mask,
  58. {
  59. styles: {
  60. opacity: 0,
  61. },
  62. duration: 200, //ms
  63. timingFunction: 'linear',
  64. delay: 0 //ms
  65. }
  66. )
  67. let height = uni.upx2px(1000);
  68. animation.transition(
  69. that.$refs.panel,
  70. {
  71. styles: {
  72. transform: `transform: translate(0px,${height}px)`
  73. },
  74. duration: 200, //ms
  75. timingFunction: 'linear',
  76. delay: 0 //ms
  77. },
  78. () => {
  79. uni.$emit("devTools_panelHideSuccess")
  80. }
  81. )
  82. },
  83. }
  84. }