fix: 🐛 Skip setting cellHeight in setDimensions

cellHeight (row height technically) is now handled by hyperlist
directly, so no need to do it manually
This commit is contained in:
Faris Ansari 2018-11-20 13:34:04 +01:00
parent 6fe075467d
commit 89f13b530a

View File

@ -125,7 +125,6 @@ export default class Style {
this.distributeRemainingWidth(); this.distributeRemainingWidth();
this.setColumnStyle(); this.setColumnStyle();
this.compensateScrollbarWidth(); this.compensateScrollbarWidth();
this.setDefaultCellHeight();
this.setBodyStyle(); this.setBodyStyle();
} }
@ -228,12 +227,10 @@ export default class Style {
compensateScrollbarWidth() { compensateScrollbarWidth() {
if (!$.hasVerticalOverflow($('.dt-body', this.bodyScrollable))) return; if (!$.hasVerticalOverflow($('.dt-body', this.bodyScrollable))) return;
requestAnimationFrame(() => { const scrollbarWidth = $.scrollbarWidth();
const scrollbarWidth = $.scrollbarWidth(); const lastCol = this.datamanager.getColumn(-1);
const lastCol = this.datamanager.getColumn(-1); const width = lastCol.width - scrollbarWidth;
const width = lastCol.width - scrollbarWidth; this.columnmanager.setColumnWidth(lastCol.colIndex, width);
this.columnmanager.setColumnWidth(lastCol.colIndex, width);
});
} }
distributeRemainingWidth() { distributeRemainingWidth() {
@ -254,25 +251,6 @@ export default class Style {
}); });
} }
setDefaultCellHeight() {
if (this.options.dynamicRowHeight) return;
if (this.__cellHeightSet) return;
const $firstCell = $('.dt-cell--header', this.instance.header);
if (!$firstCell) return;
const height = this.options.cellHeight || $.style($firstCell, 'height');
if (height) {
this.setCellHeight(height);
this.__cellHeightSet = true;
}
}
setCellHeight(height) {
this.setStyle('.dt-cell__content, .dt-cell__edit', {
height: height + 'px'
});
}
setColumnStyle() { setColumnStyle() {
// align columns // align columns
this.datamanager.getColumns() this.datamanager.getColumns()
@ -292,7 +270,6 @@ export default class Style {
this.columnmanager.setColumnHeaderWidth(column.colIndex); this.columnmanager.setColumnHeaderWidth(column.colIndex);
this.columnmanager.setColumnWidth(column.colIndex); this.columnmanager.setColumnWidth(column.colIndex);
}); });
this.setBodyStyle();
} }
refreshColumnWidth() { refreshColumnWidth() {
@ -304,26 +281,24 @@ export default class Style {
} }
setBodyStyle() { setBodyStyle() {
requestAnimationFrame(() => { const width = $.style(this.header, 'width');
const width = $.style(this.header, 'width');
$.style(this.bodyScrollable, {
width: width + 'px'
});
// when there are less rows than the container
// adapt the container height
const height = $.getStyle(this.bodyScrollable, 'height');
const scrollHeight = (this.bodyRenderer.hyperlist || {})._scrollHeight || Infinity;
if (scrollHeight < height) {
$.style(this.bodyScrollable, { $.style(this.bodyScrollable, {
width: width + 'px' height: (scrollHeight + 1) + 'px'
}); });
}
// when there are less rows than the container $.style(this.bodyScrollable, {
// adapt the container height marginTop: $.style(this.header, 'height') + 'px'
const height = $.getStyle(this.bodyScrollable, 'height');
const scrollHeight = (this.bodyRenderer.hyperlist || {})._scrollHeight || Infinity;
if (scrollHeight < height) {
$.style(this.bodyScrollable, {
height: (scrollHeight + 1) + 'px'
});
}
$.style(this.bodyScrollable, {
marginTop: $.style(this.header, 'height') + 'px'
});
}); });
} }