Example05Mirrored.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <div>
  3. <input type="checkbox" v-model="draggable"/> Draggable
  4. <input type="checkbox" v-model="resizable"/> Resizable
  5. <input type="checkbox" v-model="mirrored"/> Mirrored
  6. <br/>
  7. <grid-layout :layout.sync="layout"
  8. :col-num="12"
  9. :row-height="30"
  10. :is-draggable="draggable"
  11. :is-resizable="resizable"
  12. :is-mirrored="mirrored"
  13. :vertical-compact="true"
  14. :use-css-transforms="true"
  15. >
  16. <grid-item v-for="item in layout"
  17. :static="item.static"
  18. :x="item.x"
  19. :y="item.y"
  20. :w="item.w"
  21. :h="item.h"
  22. :i="item.i"
  23. >
  24. <span class="text">{{item.i}}</span>
  25. </grid-item>
  26. </grid-layout>
  27. </div>
  28. </template>
  29. <script>
  30. import { GridLayout, GridItem } from "vue-grid-layout"
  31. export default {
  32. components: {
  33. GridLayout,
  34. GridItem
  35. },
  36. data() {
  37. return {
  38. layout: [
  39. {"x":0,"y":0,"w":2,"h":2,"i":"0", static: false},
  40. {"x":2,"y":0,"w":2,"h":4,"i":"1", static: true},
  41. {"x":4,"y":0,"w":2,"h":5,"i":"2", static: false},
  42. {"x":6,"y":0,"w":2,"h":3,"i":"3", static: false},
  43. {"x":8,"y":0,"w":2,"h":3,"i":"4", static: false},
  44. {"x":10,"y":0,"w":2,"h":3,"i":"5", static: false},
  45. {"x":0,"y":5,"w":2,"h":5,"i":"6", static: false},
  46. {"x":2,"y":5,"w":2,"h":5,"i":"7", static: false},
  47. {"x":4,"y":5,"w":2,"h":5,"i":"8", static: false},
  48. {"x":6,"y":3,"w":2,"h":4,"i":"9", static: true},
  49. {"x":8,"y":4,"w":2,"h":4,"i":"10", static: false},
  50. {"x":10,"y":4,"w":2,"h":4,"i":"11", static: false},
  51. {"x":0,"y":10,"w":2,"h":5,"i":"12", static: false},
  52. {"x":2,"y":10,"w":2,"h":5,"i":"13", static: false},
  53. {"x":4,"y":8,"w":2,"h":4,"i":"14", static: false},
  54. {"x":6,"y":8,"w":2,"h":4,"i":"15", static: false},
  55. {"x":8,"y":10,"w":2,"h":5,"i":"16", static: false},
  56. {"x":10,"y":4,"w":2,"h":2,"i":"17", static: false},
  57. {"x":0,"y":9,"w":2,"h":3,"i":"18", static: false},
  58. {"x":2,"y":6,"w":2,"h":2,"i":"19", static: false}
  59. ],
  60. draggable: true,
  61. resizable: true,
  62. mirrored: true,
  63. index: 0
  64. }
  65. },
  66. methods: {
  67. }
  68. }
  69. </script>
  70. <style scoped>
  71. .vue-grid-layout {
  72. background: #eee;
  73. }
  74. .vue-grid-item:not(.vue-grid-placeholder) {
  75. background: #ccc;
  76. border: 1px solid black;
  77. }
  78. .vue-grid-item .resizing {
  79. opacity: 0.9;
  80. }
  81. .vue-grid-item .static {
  82. background: #cce;
  83. }
  84. .vue-grid-item .text {
  85. font-size: 24px;
  86. text-align: center;
  87. position: absolute;
  88. top: 0;
  89. bottom: 0;
  90. left: 0;
  91. right: 0;
  92. margin: auto;
  93. height: 100%;
  94. width: 100%;
  95. }
  96. .vue-grid-item .no-drag {
  97. height: 100%;
  98. width: 100%;
  99. }
  100. .vue-grid-item .minMax {
  101. font-size: 12px;
  102. }
  103. .vue-grid-item .add {
  104. cursor: pointer;
  105. }
  106. .vue-draggable-handle {
  107. position: absolute;
  108. width: 20px;
  109. height: 20px;
  110. top: 0;
  111. left: 0;
  112. background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10'><circle cx='5' cy='5' r='5' fill='#999999'/></svg>") no-repeat;
  113. background-position: bottom right;
  114. padding: 0 8px 8px 0;
  115. background-repeat: no-repeat;
  116. background-origin: content-box;
  117. box-sizing: border-box;
  118. cursor: pointer;
  119. }
  120. </style>