* Update current cell height - see `GridStackOptions.cellHeight` for format by updating eh Browser CSS variable. * * @param val the cell height. Options: * - `undefined`: cells content will be made square (match width minus margin) * - `0`: the CSS will be generated by the applicatio
(val?: numberOrString)
| 902 | * grid.cellHeight('auto'); // auto-size based on content |
| 903 | */ |
| 904 | public cellHeight(val?: numberOrString): GridStack { |
| 905 | |
| 906 | // if not called internally, check if we're changing mode |
| 907 | if (val !== undefined) { |
| 908 | if (this._isAutoCellHeight !== (val === 'auto')) { |
| 909 | this._isAutoCellHeight = (val === 'auto'); |
| 910 | this._updateResizeEvent(); |
| 911 | } |
| 912 | } |
| 913 | if (val === 'initial' || val === 'auto') { val = undefined; } |
| 914 | |
| 915 | // make item content be square |
| 916 | if (val === undefined) { |
| 917 | const marginDiff = - (this.opts.marginRight as number) - (this.opts.marginLeft as number) |
| 918 | + (this.opts.marginTop as number) + (this.opts.marginBottom as number); |
| 919 | val = this.cellWidth() + marginDiff; |
| 920 | } |
| 921 | |
| 922 | const data = Utils.parseHeight(val); |
| 923 | if (this.opts.cellHeightUnit === data.unit && this.opts.cellHeight === data.h) { |
| 924 | return this; |
| 925 | } |
| 926 | this.opts.cellHeightUnit = data.unit; |
| 927 | this.opts.cellHeight = data.h; |
| 928 | |
| 929 | // finally update var and container |
| 930 | this.el.style.setProperty('--gs-cell-height', `${this.opts.cellHeight}${this.opts.cellHeightUnit}`); |
| 931 | this._updateContainerHeight(); |
| 932 | this.resizeToContentCheck(); |
| 933 | |
| 934 | return this; |
| 935 | } |
| 936 | |
| 937 | /** Gets current cell width. */ |
| 938 | /** |
no test coverage detected