|
| 1 | +<template> |
| 2 | + <div style="width:100%;height:2000px;"> |
| 3 | + <div class="layoutJSON"> |
| 4 | + Displayed as <code>[x, y, w, h]</code>: |
| 5 | + <div class="columns"> |
| 6 | + <div v-for="item in layout"> |
| 7 | + <b>{{item.i}}</b>: [{{item.x}}, {{item.y}}, {{item.w}}, {{item.h}}] |
| 8 | + </div> |
| 9 | + </div> |
| 10 | + </div> |
| 11 | + <hr/> |
| 12 | + <input type="checkbox" v-model="draggable"/> Draggable |
| 13 | + <input type="checkbox" v-model="resizable"/> Resizable |
| 14 | + <input type="checkbox" v-model="bounded"/> Bounded |
| 15 | + <br/> |
| 16 | + <div style="width:100%;margin-top: 10px;height:100%;"> |
| 17 | + <grid-layout :layout.sync="layout" |
| 18 | + :col-num="12" |
| 19 | + :row-height="30" |
| 20 | + :is-draggable="draggable" |
| 21 | + :is-resizable="resizable" |
| 22 | + :is-bounded="bounded" |
| 23 | + :vertical-compact="true" |
| 24 | + :use-css-transforms="true" |
| 25 | + > |
| 26 | + <grid-item v-for="item in layout" |
| 27 | + :static="item.static" |
| 28 | + :x="item.x" |
| 29 | + :y="item.y" |
| 30 | + :w="item.w" |
| 31 | + :h="item.h" |
| 32 | + :i="item.i" |
| 33 | + > |
| 34 | + <span class="text">{{item.i}}</span> |
| 35 | + </grid-item> |
| 36 | + </grid-layout> |
| 37 | + </div> |
| 38 | + </div> |
| 39 | +</template> |
| 40 | + |
| 41 | +<script> |
| 42 | +import { GridLayout, GridItem } from "vue-grid-layout" |
| 43 | +
|
| 44 | +export default { |
| 45 | + components: { |
| 46 | + GridLayout, |
| 47 | + GridItem |
| 48 | + }, |
| 49 | + data() { |
| 50 | + return { |
| 51 | + layout: [ |
| 52 | + {"x":0,"y":0,"w":2,"h":2,"i":"0"}, |
| 53 | + {"x":2,"y":0,"w":2,"h":4,"i":"1"}, |
| 54 | + {"x":4,"y":0,"w":2,"h":5,"i":"2"}, |
| 55 | + {"x":6,"y":0,"w":2,"h":3,"i":"3"}, |
| 56 | + {"x":8,"y":0,"w":2,"h":3,"i":"4"}, |
| 57 | + {"x":10,"y":0,"w":2,"h":3,"i":"5"}, |
| 58 | + {"x":0,"y":5,"w":2,"h":5,"i":"6"}, |
| 59 | + {"x":2,"y":5,"w":2,"h":5,"i":"7"}, |
| 60 | + {"x":4,"y":5,"w":2,"h":5,"i":"8"}, |
| 61 | + {"x":6,"y":4,"w":2,"h":4,"i":"9"}, |
| 62 | + {"x":8,"y":4,"w":2,"h":4,"i":"10"}, |
| 63 | + {"x":10,"y":4,"w":2,"h":4,"i":"11"}, |
| 64 | + {"x":0,"y":10,"w":2,"h":5,"i":"12"}, |
| 65 | + {"x":2,"y":10,"w":2,"h":5,"i":"13"}, |
| 66 | + {"x":4,"y":8,"w":2,"h":4,"i":"14"}, |
| 67 | + {"x":6,"y":8,"w":2,"h":4,"i":"15"}, |
| 68 | + {"x":8,"y":10,"w":2,"h":5,"i":"16"}, |
| 69 | + {"x":10,"y":4,"w":2,"h":2,"i":"17"}, |
| 70 | + {"x":0,"y":9,"w":2,"h":3,"i":"18"}, |
| 71 | + {"x":2,"y":6,"w":2,"h":2,"i":"19"} |
| 72 | + ], |
| 73 | + draggable: true, |
| 74 | + resizable: true, |
| 75 | + bounded: true |
| 76 | + } |
| 77 | + } |
| 78 | +} |
| 79 | +</script> |
| 80 | + |
| 81 | +<style scoped> |
| 82 | +.vue-grid-layout { |
| 83 | + background: #eee; |
| 84 | +} |
| 85 | +
|
| 86 | +.vue-grid-item:not(.vue-grid-placeholder) { |
| 87 | + background: #ccc; |
| 88 | + border: 1px solid black; |
| 89 | +} |
| 90 | +
|
| 91 | +.vue-grid-item .resizing { |
| 92 | + opacity: 0.9; |
| 93 | +} |
| 94 | +
|
| 95 | +.vue-grid-item .static { |
| 96 | + background: #cce; |
| 97 | +} |
| 98 | +
|
| 99 | +.vue-grid-item .text { |
| 100 | + font-size: 24px; |
| 101 | + text-align: center; |
| 102 | + position: absolute; |
| 103 | + top: 0; |
| 104 | + bottom: 0; |
| 105 | + left: 0; |
| 106 | + right: 0; |
| 107 | + margin: auto; |
| 108 | + height: 100%; |
| 109 | + width: 100%; |
| 110 | +} |
| 111 | +
|
| 112 | +.vue-grid-item .no-drag { |
| 113 | + height: 100%; |
| 114 | + width: 100%; |
| 115 | +} |
| 116 | +
|
| 117 | +.vue-grid-item .minMax { |
| 118 | + font-size: 12px; |
| 119 | +} |
| 120 | +
|
| 121 | +.vue-grid-item .add { |
| 122 | + cursor: pointer; |
| 123 | +} |
| 124 | +
|
| 125 | +.vue-draggable-handle { |
| 126 | + position: absolute; |
| 127 | + width: 20px; |
| 128 | + height: 20px; |
| 129 | + top: 0; |
| 130 | + left: 0; |
| 131 | + 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; |
| 132 | + background-position: bottom right; |
| 133 | + padding: 0 8px 8px 0; |
| 134 | + background-repeat: no-repeat; |
| 135 | + background-origin: content-box; |
| 136 | + box-sizing: border-box; |
| 137 | + cursor: pointer; |
| 138 | +} |
| 139 | +
|
| 140 | +.layoutJSON { |
| 141 | + background: #ddd; |
| 142 | + border: 1px solid black; |
| 143 | + margin-top: 10px; |
| 144 | + padding: 10px; |
| 145 | +} |
| 146 | +
|
| 147 | +.columns { |
| 148 | + -moz-columns: 120px; |
| 149 | + -webkit-columns: 120px; |
| 150 | + columns: 120px; |
| 151 | +} |
| 152 | +
|
| 153 | +</style> |
0 commit comments