drawerWindow.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template name="drawerWindow">
  2. <view :style="{background:background,zIndex:zIndex, top:top+'px'}">
  3. <view class="DrawerClose" :class="show ? 'show':''" @tap="hideModal">
  4. <text class="cuIcon-pullright"></text>
  5. </view>
  6. <scroll-view scroll-y class="DrawerWindow" :class="show ? 'show':''" :style="{width:width,padding:padding, zIndex:zIndex+1, background:slotBg}" @tap.stop="stopFun" @touchstart="Dever.slide" @touchend="end">
  7. <view class="cu-list menu card-menu margin-top-xl margin-bottom-xl shadow-lg" v-if="show">
  8. <slot name="links"></slot>
  9. </view>
  10. </scroll-view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. name: "drawerWindow",
  16. props: {
  17. show : {
  18. type : Boolean,
  19. default : false
  20. },
  21. direction : {
  22. type : String,
  23. default : 'left'
  24. },
  25. width : {
  26. type : String,
  27. default : '60%'
  28. },
  29. background:{
  30. type : String,
  31. default : 'rgba(0, 0, 0, 0.5)'
  32. },
  33. slotBg:{
  34. type : String,
  35. default : 'rgba(255, 255, 255, 1)'
  36. },
  37. padding :{
  38. type : String,
  39. default : '30rpx'
  40. },
  41. zIndex : {
  42. type : Number,
  43. default : 1
  44. },
  45. // #ifdef H5
  46. top:{
  47. type : Number,
  48. default : 44
  49. },
  50. // #endif
  51. // #ifndef H5
  52. top:{
  53. type : Number,
  54. default : 0
  55. },
  56. // #endif
  57. },
  58. data() {
  59. return {
  60. };
  61. },
  62. methods:{
  63. closeDrawer : function(){
  64. this.$emit('closeDrawer');
  65. },
  66. end : function(e) {
  67. var type = this.Dever.slideEnd(e);
  68. if (type == 3 || type == 4) {
  69. this.closeDrawer();
  70. }
  71. },
  72. showModal : function(e) {
  73. this.show = true;
  74. },
  75. hideModal : function(e) {
  76. this.closeDrawer();
  77. },
  78. stopFun : function() {
  79. }
  80. }
  81. }
  82. </script>
  83. <style>
  84. .DrawerWindow {
  85. position: absolute;
  86. width: 85vw;
  87. height: 100vh;
  88. left: 0;
  89. top: 0;
  90. transform: scale(0.9, 0.9) translateX(-100%);
  91. opacity: 0;
  92. pointer-events: none;
  93. transition: all 0.4s;
  94. }
  95. .DrawerWindow.show {
  96. transform: scale(1, 1) translateX(0%);
  97. opacity: 1;
  98. pointer-events: all;
  99. }
  100. .DrawerClose {
  101. position: absolute;
  102. width: 40vw;
  103. height: 100vh;
  104. right: 0;
  105. top: 0;
  106. color: transparent;
  107. padding-bottom: 30upx;
  108. display: flex;
  109. align-items: flex-end;
  110. justify-content: center;
  111. background-image: linear-gradient(90deg, rgba(0, 0, 0, 0.01), rgba(0, 0, 0, 0.6));
  112. letter-spacing: 5px;
  113. font-size: 50upx;
  114. opacity: 0;
  115. pointer-events: none;
  116. transition: all 0.4s;
  117. }
  118. .DrawerClose.show {
  119. opacity: 1;
  120. pointer-events: all;
  121. width: 15vw;
  122. color: #fff;
  123. }
  124. </style>