Skip to content

wrong rowHeight ratio #504

@tasiot

Description

@tasiot

When using margin and rowHeight as "*1.4" or "/1.4", block don't respect this ratio.
Indeed, rowHeight is calculated by curColWidth but it includes a margin, so ratio is no correctly calculated.

Solution consists to substract margin in curColWidth, calculate curRowHeight and add margin in curRowHeight.

if (gridster.colWidth === 'auto') {
	gridster.curColWidth = (gridster.curWidth + (gridster.outerMargin ? -gridster.margins[0] : gridster.margins[0])) / gridster.columns;
} else {
	gridster.curColWidth = gridster.colWidth;
}
var colWidthNoMargin = gridster.curColWidth - gridster.margins[0];

gridster.curRowHeight = gridster.rowHeight;
if (typeof gridster.rowHeight === 'string') {
	if (gridster.rowHeight === 'match') {
		gridster.curRowHeight = (gridster.curColWidth);
	} else if (gridster.rowHeight.indexOf('*') !== -1) {
		gridster.curRowHeight = (colWidthNoMargin * gridster.rowHeight.replace('*', '').replace(' ', '') + gridster.margins[1]);
	} else if (gridster.rowHeight.indexOf('/') !== -1) {
		gridster.curRowHeight = (colWidthNoMargin / gridster.rowHeight.replace('/', '').replace(' ', '') + gridster.margins[1]);
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions