From 0b2e92c62756458e2bc9271581baf3261427abc6 Mon Sep 17 00:00:00 2001 From: Cheng Xiaoyu Date: Thu, 5 Nov 2020 19:28:28 +0800 Subject: [PATCH] Update gridstack.ts Bug fix: Init with marginTop prop or other margin props will turn height to 1 when resize a grid --- src/gridstack.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gridstack.ts b/src/gridstack.ts index c4237b1f0..dccfd9af4 100644 --- a/src/gridstack.ts +++ b/src/gridstack.ts @@ -1854,6 +1854,10 @@ export class GridStack { this.opts.marginLeft = data.height; delete this.opts.margin; } + + //without this.opts.margin, getMargin method will return undefined, and affect resize behavior + if(!this.opts.margin) this.opts.margin = Math.round((this.opts.marginTop + this.opts.marginBottom) / 2); + this.opts.marginUnit = data.unit; // in case side were spelled out, use those units instead... return this; }