graceDrawer.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <view class="grace-drawer-shade" v-if="show" @tap.stop="closeDrawer" @touchmove.stop="" :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. created:function(){
  60. // #ifdef H5
  61. this.top = 44;
  62. // #endif
  63. }
  64. }
  65. </script>
  66. <style>
  67. @keyframes gdSlideLeft{ from {left:-300px; } 100% { left:0px; }}
  68. .gdSlideLeft {animation:gdSlideLeft 200ms linear; left:0;}
  69. @keyframes gdSlideRight{ from {right:-300px; } 100% { right:0px; }}
  70. .gdSlideRight {animation:gdSlideRight 200ms linear; right:0;}
  71. .grace-drawer-shade{position:fixed; width:100%; height:100%; top:0; left:0; z-index:1; background:rgba(0, 0, 0, 0.5);}
  72. .grace-drawer-shade-nav{height:100%; background:#FFFFFF; position:absolute; top:0; z-index:2; box-sizing:border-box;}
  73. </style>