Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. <template>
  2. <transition name="modal">
  3. <div class="modal-mask" @click="close" v-show="show">
  4. <div class="modal-container" @click.stop="close">
  5. <slot></slot>
  6. </div>
  7. </div>
  8. </transition>
  9. </template>
  10.  
  11. <script>
  12. export default {
  13. props: ['show'],
  14.  
  15. mounted: function () {
  16. document.addEventListener("keydown", (e) => {
  17. if (this.show && e.keyCode == 27) {
  18. this.close()
  19. }
  20. })
  21. },
  22.  
  23. methods: {
  24. close: function() {
  25. this.$emit('close')
  26. }
  27. }
  28. }
  29. </script>
  30.  
  31. <style scoped>
  32. * {
  33. box-sizing: border-box;
  34. }
  35.  
  36. .modal-mask {
  37. position: fixed;
  38. z-index: 9998;
  39. top: 0;
  40. left: 0;
  41. width: 100%;
  42. height: 100%;
  43. background-color: rgba(0, 0, 0, .5);
  44. transition: opacity .3s ease;
  45. overflow-x: auto;
  46. }
  47.  
  48. .modal-container {
  49. width: 75%;
  50. height: 100%;
  51. margin: 0px auto;
  52. padding: 20px 30px;
  53. background-color: #fff;
  54. border-radius: 2px;
  55. box-shadow: 0 2px 8px rgba(0, 0, 0, .33);
  56. transition: all .3s ease;
  57. }
  58.  
  59. .modal-body {
  60. margin: 20px 0;
  61. }
  62.  
  63. /*
  64. * The following styles are auto-applied to elements with
  65. * transition="modal" when their visibility is toggled
  66. * by Vue.js.
  67. *
  68. * You can easily play with the modal transition by editing
  69. * these styles.
  70. */
  71.  
  72. .modal-enter {
  73. opacity: 0;
  74. }
  75.  
  76. .modal-leave-active {
  77. opacity: 0;
  78. }
  79.  
  80. .modal-enter .modal-container,
  81. .modal-leave-active .modal-container {
  82. -webkit-transform: scale(1.1);
  83. transform: scale(1.1);
  84. }
  85. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement