Skip to content

Commit a3978ee

Browse files
authored
Merge pull request #24 from true0r/master
fix height of container and center alignment after remove item
2 parents ea60cc0 + 3e4119a commit a3978ee

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

dist/index.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@
250250
return this.gridWidth < 0 ? this.windowWidth : Math.min(this.windowWidth, this.gridWidth);
251251
},
252252
height: function() {
253-
return Math.ceil(this.items.length / this.rowCount) * this.cellHeight;
253+
return Math.ceil(this.list.length / this.rowCount) * this.cellHeight;
254254
},
255255
style: function() {
256256
return {
@@ -262,7 +262,7 @@
262262
},
263263
rowShift: function() {
264264
if (this.center) {
265-
var contentWidth = this.items.length * this.cellWidth, rowShift = contentWidth < this.gridResponsiveWidth ? (this.gridResponsiveWidth - contentWidth) / 2 : this.gridResponsiveWidth % this.cellWidth / 2;
265+
var contentWidth = this.list.length * this.cellWidth, rowShift = contentWidth < this.gridResponsiveWidth ? (this.gridResponsiveWidth - contentWidth) / 2 : this.gridResponsiveWidth % this.cellWidth / 2;
266266
return Math.floor(rowShift);
267267
}
268268
return 0;
@@ -491,12 +491,15 @@
491491
created: function() {
492492
window.addEventListener("resize", this.getWindowSize), this.getWindowSize();
493493
},
494+
mounted: function() {
495+
this.getWindowSize();
496+
},
494497
beforeDestroy: function() {
495498
window.removeEventListener("resize", this.getWindowSize);
496499
},
497500
methods: {
498501
getWindowSize: function() {
499-
this.windowHeight = window.innerHeight, this.windowWidth = window.innerWidth;
502+
this.$el && (this.windowHeight = this.$el.clientHeight, this.windowWidth = this.$el.clientWidth);
500503
}
501504
}
502505
};
@@ -558,7 +561,7 @@
558561
on: {
559562
mousedown: _vm.mousedown,
560563
touchstart: function($event) {
561-
$event.stopPropagation(), _vm.mousedown($event);
564+
return $event.stopPropagation(), _vm.mousedown($event);
562565
}
563566
}
564567
}, [ _vm._t("default") ], 2);

src/Grid.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export default {
9797
},
9898
9999
height () {
100-
return Math.ceil(this.items.length / this.rowCount) *
100+
return Math.ceil(this.list.length / this.rowCount) *
101101
this.cellHeight
102102
},
103103
@@ -113,7 +113,7 @@ export default {
113113
114114
rowShift () {
115115
if (this.center) {
116-
let contentWidth = this.items.length * this.cellWidth
116+
let contentWidth = this.list.length * this.cellWidth
117117
let rowShift = contentWidth < this.gridResponsiveWidth
118118
? (this.gridResponsiveWidth - contentWidth) / 2
119119
: (this.gridResponsiveWidth % this.cellWidth) / 2

0 commit comments

Comments
 (0)