Skip to content

Commit 1f4eaeb

Browse files
authored
Merge pull request jbaysolutions#5 from jbaysolutions/vue2
Vue 2
2 parents ca6c890 + acb4881 commit 1f4eaeb

20 files changed

+8452
-19843
lines changed

README.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# vue-grid-layout
22

3-
vue-grid-layout is a grid layout system, like [Gridster](http://gridster.net), for Vue.js.
3+
vue-grid-layout is a grid layout system, like [Gridster](http://gridster.net), for Vue.js. **Heavily inspired in [React-Grid-Layout](https://github.com/STRML/react-grid-layout)**
44

5+
### **Current version:** 2.0.0 (Supports Vue 2.0+)
56

6-
**Heavily inspired in [React-Grid-Layout](https://github.com/STRML/react-grid-layout)**
7+
### **For Vue 1 use version [1.0.0](https://github.com/jbaysolutions/vue-grid-layout/tree/1.0.0)**
78

9+
<br/>
810

911
[**[Demo](https://jbaysolutions.github.io/vue-grid-layout/examples/01-basic.html) | [Changelog](/CHANGELOG.md)**]
1012

@@ -50,7 +52,13 @@ Install the vue-grid-layout [package](https://www.npmjs.org/package/vue-grid-lay
5052

5153
## Usage
5254

53-
npm install vue-grid-layout
55+
npm install vue-grid-layout
56+
57+
or include the script in your html (download from [releases](https://github.com/jbaysolutions/vue-grid-layout/releases)):
58+
59+
```html
60+
<script src="vue-grid-layout.min.js"></script>
61+
````
5462

5563
```javascript
5664

@@ -96,7 +104,7 @@ npm install vue-grid-layout
96104
````html
97105

98106
<grid-layout
99-
:layout.sync="layout"
107+
:layout="layout"
100108
:col-num="12"
101109
:row-height="30"
102110
:is-draggable="true"
@@ -107,10 +115,10 @@ npm install vue-grid-layout
107115
>
108116

109117
<grid-item v-for="item in layout"
110-
:x.sync="item.x"
111-
:y.sync="item.y"
112-
:w.sync="item.w"
113-
:h.sync="item.h"
118+
:x="item.x"
119+
:y="item.y"
120+
:w="item.w"
121+
:h="item.h"
114122
:i="item.i">
115123
{{item.i}}
116124
</grid-item>

dist/vue-grid-layout.js

Lines changed: 121 additions & 10257 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-grid-layout.min.js

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vue-grid-layout.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/01-basic.html

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,22 @@ <h1>Vue Grid Layout Example 1 - Basic</h1>
2121
</div>
2222
</div>
2323
<div id="content">
24-
<grid-layout :layout.sync="layout" :col-num="12" :row-height="30" :is-draggable="true" :vertical-compact="true">
24+
<!--<button @click="decreaseWidth">Decrease Width</button>
25+
<button @click="increaseWidth">Increase Width</button>
26+
<button @click="addItem">Add an item</button>-->
27+
<grid-layout :layout="layout"
28+
:col-num="12"
29+
:row-height="30"
30+
:is-draggable="true"
31+
:is-resizable="true"
32+
:vertical-compact="true"
33+
:use-css-transforms="true"
34+
>
2535
<grid-item v-for="item in layout"
26-
:x.sync="item.x"
27-
:y.sync="item.y"
28-
:w.sync="item.w"
29-
:h.sync="item.h"
36+
:x="item.x"
37+
:y="item.y"
38+
:w="item.w"
39+
:h="item.h"
3040
:i="item.i"
3141
>
3242
<span class="text">{{item.i}}</span>
@@ -35,7 +45,7 @@ <h1>Vue Grid Layout Example 1 - Basic</h1>
3545
</div>
3646

3747
</div>
38-
<script src="vue.js"></script>
48+
<script src="vue.min.js"></script>
3949
<script src="../dist/vue-grid-layout.js"></script>
4050
<script src="01-basic.js"></script>
4151
</body>

examples/01-basic.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,40 @@ new Vue({
3737
},
3838
data: {
3939
layout: testLayout,
40+
index: 0
4041
},
41-
});
42+
/*
43+
mounted: function () {
44+
this.index = this.layout.length;
45+
},
46+
methods: {
47+
increaseWidth: function(item) {
48+
var width = document.getElementById("content").offsetWidth;
49+
width += 20;
50+
document.getElementById("content").style.width = width+"px";
51+
},
52+
decreaseWidth: function(item) {
4253
54+
var width = document.getElementById("content").offsetWidth;
55+
width -= 20;
56+
document.getElementById("content").style.width = width+"px";
57+
},
58+
removeItem: function(item) {
59+
//console.log("### REMOVE " + item.i);
60+
this.layout.splice(this.layout.indexOf(item), 1);
61+
},
62+
addItem: function() {
63+
var self = this;
64+
//console.log("### LENGTH: " + this.layout.length);
65+
var item = {"x":0,"y":0,"w":2,"h":2,"i":this.index+"", whatever: "bbb"};
66+
this.index++;
67+
this.layout.push(item);
68+
}
69+
}
70+
*/
71+
});
4372

73+
/*
4474
function generateLayout() {
4575
return _.map(_.range(0, 25), function (item, i) {
4676
var y = Math.ceil(Math.random() * 4) + 1;
@@ -53,7 +83,7 @@ function generateLayout() {
5383
static: Math.random() < 0.05
5484
};
5585
});
56-
}
86+
}*/
5787

5888

5989

0 commit comments

Comments
 (0)