* Updates the margins which will set all 4 sides at once - see `GridStackOptions.margin` for format options. * Supports CSS string format of 1, 2, or 4 values or a single number. * * @param value margin value - can be: * - Single number: `10` (applies to all sides) * - Two values:
(value: numberOrString)
| 1762 | * grid.margin('5px 10px 15px 20px'); // Different for each side |
| 1763 | */ |
| 1764 | public margin(value: numberOrString): GridStack { |
| 1765 | const isMultiValue = (typeof value === 'string' && value.split(' ').length > 1); |
| 1766 | // check if we can skip... won't check if multi values (too much hassle) |
| 1767 | if (!isMultiValue) { |
| 1768 | const data = Utils.parseHeight(value); |
| 1769 | if (this.opts.marginUnit === data.unit && this.opts.margin === data.h) return; |
| 1770 | } |
| 1771 | // re-use existing margin handling |
| 1772 | this.opts.margin = value; |
| 1773 | this.opts.marginTop = this.opts.marginBottom = this.opts.marginLeft = this.opts.marginRight = undefined; |
| 1774 | this._initMargin(); |
| 1775 | |
| 1776 | return this; |
| 1777 | } |
| 1778 | |
| 1779 | /** |
| 1780 | * Returns the current margin value as a number (undefined if the 4 sides don't match). |
no test coverage detected