From 218202c16de4649458a0b4bccb5f9aa8ff221c07 Mon Sep 17 00:00:00 2001 From: Safwan Samsudeen Date: Thu, 2 Jan 2025 13:50:04 +0530 Subject: [PATCH] add auto container height --- src/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/index.js b/src/index.js index b83ac1a..f791687 100644 --- a/src/index.js +++ b/src/index.js @@ -80,12 +80,10 @@ export default class Gantt { 'lower-header-height': 'lower_header_height', 'upper-header-height': 'upper_header_height', }; - for (let name in CSS_VARIABLES) { - this.$container.style.setProperty( - '--gv-' + name, - this.options[CSS_VARIABLES[name]] + 'px', - ); + let setting = this.options[CSS_VARIABLES[name]]; + if (setting === 'auto') continue; + this.$container.style.setProperty('--gv-' + name, setting + 'px'); } this.config = { @@ -873,13 +871,15 @@ export default class Gantt { } set_dimensions() { - const { width: cur_width } = this.$svg.getBoundingClientRect(); + const { width: cur_width, height } = this.$svg.getBoundingClientRect(); const actual_width = this.$svg.querySelector('.grid .grid-row') ? this.$svg.querySelector('.grid .grid-row').getAttribute('width') : 0; if (cur_width < actual_width) { this.$svg.setAttribute('width', actual_width); } + if (this.options.container_height === 'auto') + this.$container.style.height = height + 'px'; } set_scroll_position(date) {