|
45 | 45 | :is-resizable="resizable" |
46 | 46 | :is-mirrored="mirrored" |
47 | 47 | :prevent-collision="preventCollision" |
48 | | - :vertical-compact="true" |
| 48 | + :vertical-compact="compact" |
49 | 49 | :use-css-transforms="true" |
50 | 50 | :responsive="responsive" |
51 | 51 | @layout-created="layoutCreatedEvent" |
|
68 | 68 | :max-x="item.maxX" |
69 | 69 | :min-y="item.minY" |
70 | 70 | :max-y="item.maxY" |
| 71 | + :preserve-aspect-ratio="item.preserveAspectRatio" |
71 | 72 | @resize="resize" |
72 | 73 | @move="move" |
73 | 74 | @resized="resized" |
74 | 75 | @container-resized="containerResized" |
75 | 76 | @moved="moved" |
76 | 77 | > |
77 | 78 | <!--<custom-drag-element :text="item.i"></custom-drag-element>--> |
78 | | - <test-element :text="item.i"></test-element> |
| 79 | + <test-element :text="item.i" @removeItem="removeItem($event)"></test-element> |
79 | 80 | <!--<button @click="clicked">CLICK ME!</button>--> |
80 | 81 | </grid-item> |
81 | 82 | </grid-layout> |
|
119 | 120 | let testLayout = [ |
120 | 121 | {"x":0,"y":0,"w":2,"h":2,"i":"0", resizable: true, draggable: true, static: false, minY: 0, maxY: 2}, |
121 | 122 | {"x":2,"y":0,"w":2,"h":4,"i":"1", resizable: null, draggable: null, static: true}, |
122 | | - {"x":4,"y":0,"w":2,"h":5,"i":"2", resizable: false, draggable: false, static: false, minX: 4, maxX: 4, minW: 2, maxW: 2}, |
| 123 | + {"x":4,"y":0,"w":2,"h":5,"i":"2", resizable: false, draggable: false, static: false, minX: 4, maxX: 4, minW: 2, maxW: 2, preserveAspectRatio: true}, |
123 | 124 | {"x":6,"y":0,"w":2,"h":3,"i":"3", resizable: false, draggable: false, static: false}, |
124 | 125 | {"x":8,"y":0,"w":2,"h":3,"i":"4", resizable: false, draggable: false, static: false}, |
125 | 126 | {"x":10,"y":0,"w":2,"h":3,"i":"5", resizable: false, draggable: false, static: false}, |
|
139 | 140 | {"x":2,"y":6,"w":2,"h":2,"i":"19", resizable: false, draggable: false, static: false} |
140 | 141 | ]; |
141 | 142 |
|
| 143 | + /*let testLayout = [ |
| 144 | + { x: 0, y: 0, w: 2, h: 2, i: "0" }, |
| 145 | + { x: 2, y: 0, w: 2, h: 2, i: "1" }, |
| 146 | + { x: 4, y: 0, w: 2, h: 2, i: "2" }, |
| 147 | + { x: 6, y: 0, w: 2, h: 2, i: "3" }, |
| 148 | + { x: 8, y: 0, w: 2, h: 2, i: "4" }, |
| 149 | + ];*/ |
| 150 | +
|
142 | 151 | export default { |
143 | 152 | name: 'app', |
144 | 153 | components: { |
|
156 | 165 | mirrored: false, |
157 | 166 | responsive: true, |
158 | 167 | preventCollision: false, |
| 168 | + compact: true, |
159 | 169 | rowHeight: 30, |
160 | 170 | colNum: 12, |
161 | 171 | index: 0, |
|
180 | 190 | width -= 20; |
181 | 191 | document.getElementById("content").style.width = width+"px"; |
182 | 192 | }, |
183 | | - removeItem: function(item) { |
184 | | - //console.log("### REMOVE " + item.i); |
185 | | - this.layout.splice(this.layout.indexOf(item), 1); |
| 193 | + removeItem: function(i) { |
| 194 | + console.log("### REMOVE " + i); |
| 195 | + const index = this.layout.map(item => item.i).indexOf(i); |
| 196 | + this.layout.splice(index, 1); |
186 | 197 | }, |
187 | 198 | addItem: function() { |
188 | 199 | // let self = this; |
|
192 | 203 | this.layout.push(item); |
193 | 204 | }, |
194 | 205 | addItemDynamically: function() { |
| 206 | + const x = (this.layout.length * 2) % (this.colNum || 12); |
| 207 | + const y = this.layout.length + (this.colNum || 12); |
| 208 | + console.log("X=" + x + " Y=" + y) |
195 | 209 | let item = { |
196 | | - x: (this.layout.length * 2) % (this.colNum || 12), |
197 | | - y: this.layout.length + (this.colNum || 12), |
| 210 | + x: x, |
| 211 | + y: y, |
198 | 212 | w: 2, |
199 | 213 | h: 2, |
200 | 214 | i: this.index+"", |
|
0 commit comments