graceDrawer.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <view class="grace-drawer-shade" v-if="show" :style="{background:background,zIndex:zIndex, top:top+'px'}">
  3. <scroll-view scroll-y="true" :class="['grace-drawer-shade-nav', direction == 'left' ? 'gdSlideLeft' : 'gdSlideRight']" :style="{width:width,padding:padding, zIndex:zIndex+1, background:slotBg}" @tap.stop="stopFun" @touchstart="Dever.slide" @touchend="end">
  4. <slot name="links"></slot>
  5. </scroll-view>
  6. </view>
  7. </template>
  8. <script>
  9. export default {
  10. name: "graceDrawer",
  11. props: {
  12. show : {
  13. type : Boolean,
  14. default : false
  15. },
  16. direction : {
  17. type : String,
  18. default : 'left'
  19. },
  20. width : {
  21. type : String,
  22. default : '60%'
  23. },
  24. background:{
  25. type : String,
  26. default : 'rgba(0, 0, 0, 0.5)'
  27. },
  28. slotBg:{
  29. type : String,
  30. default : 'rgba(255, 255, 255, 1)'
  31. },
  32. padding :{
  33. type : String,
  34. default : '30rpx'
  35. },
  36. zIndex : {
  37. type : Number,
  38. default : 1
  39. },
  40. // #ifdef H5
  41. top:{
  42. type : Number,
  43. default : 44
  44. },
  45. // #endif
  46. // #ifndef H5
  47. top:{
  48. type : Number,
  49. default : 0
  50. },
  51. // #endif
  52. },
  53. methods:{
  54. closeDrawer : function(){
  55. this.$emit('closeDrawer');
  56. },
  57. end : function(e) {
  58. var type = this.Dever.slideEnd(e);
  59. if (type == 3 || type == 4) {
  60. this.closeDrawer();
  61. }
  62. },
  63. stopFun : function(){}
  64. }
  65. }
  66. </script>
  67. <style>
  68. @keyframes gdSlideLeft{ from {left:-300px; } 100% { left:0px; }}
  69. .gdSlideLeft {animation:gdSlideLeft 200ms linear; left:0;}
  70. @keyframes gdSlideRight{ from {right:-300px; } 100% { right:0px; }}
  71. .gdSlideRight1 {animation:gdSlideRight 200ms linear; right:0;}
  72. .gdSlideRight {right:0;}
  73. .grace-drawer-shade{position:fixed; width:100%; height:100%; top:0; left:0; z-index:1; background:rgba(0, 0, 0, 0.5);}
  74. .grace-drawer-shade-nav{height:100%; background:#FFFFFF; position:absolute; top:0; z-index:2; box-sizing:border-box;}
  75. </style>