graceDrawer.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <view class="grace-drawer-shade" v-if="show" @tap.stop="closeDrawer" @touchmove.stop.prevent="" :style="{background:background,zIndex:zIndex, top:top+'px'}">
  3. <view :class="['grace-drawer-shade-nav', direction == 'left' ? 'gdSlideLeft' : 'gdSlideRight']" :style="{width:width,padding:padding, zIndex:zIndex+1, background:slotBg}" @tap.stop="stopFun">
  4. <slot name="links"></slot>
  5. </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. stopFun : function(){}
  58. }
  59. }
  60. </script>
  61. <style>
  62. @keyframes gdSlideLeft{ from {left:-300px; } 100% { left:0px; }}
  63. .gdSlideLeft {animation:gdSlideLeft 200ms linear; left:0;}
  64. @keyframes gdSlideRight{ from {right:-300px; } 100% { right:0px; }}
  65. .gdSlideRight {animation:gdSlideRight 200ms linear; right:0;}
  66. .grace-drawer-shade{position:fixed; width:100%; height:100%; top:0; left:0; z-index:1; background:rgba(0, 0, 0, 0.5);}
  67. .grace-drawer-shade-nav{height:100%; background:#FFFFFF; position:absolute; top:0; z-index:2; box-sizing:border-box;}
  68. </style>