MCPcopy Index your code
hub / github.com/gridstack/gridstack.js / cellHeight

Method cellHeight

src/gridstack.ts:904–935  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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 /**

Callers 6

constructorMethod · 0.95
columnMethod · 0.95
updateOptionsMethod · 0.95
onResizeMethod · 0.95
gridstack-spec.tsFile · 0.80

Calls 5

_updateResizeEventMethod · 0.95
cellWidthMethod · 0.95
resizeToContentCheckMethod · 0.95
parseHeightMethod · 0.80

Tested by

no test coverage detected