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

Method resizable

src/dd-gridstack.ts:72–106  ·  view source on GitHub ↗

* Enable/disable/configure resizing for grid elements. * * @param el - Grid item element(s) to configure * @param opts - Resize options or command ('enable', 'disable', 'destroy', 'option', or config object) * @param key - Option key when using 'option' command * @param value - O

(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue)

Source from the content-addressed store, hash-verified

70 * dd.resizable(element, 'option', 'minWidth', 100); // Set minimum width
71 */
72 public resizable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): DDGridStack {
73 this._getDDElements(el, opts).forEach(dEl => {
74 if (opts === 'disable' || opts === 'enable') {
75 dEl.ddResizable && dEl.ddResizable[opts](); // can't create DD as it requires options for setupResizable()
76 } else if (opts === 'destroy') {
77 dEl.ddResizable && dEl.cleanResizable();
78 } else if (opts === 'option') {
79 dEl.setupResizable({ [key]: value });
80 } else {
81 const n = dEl.el.gridstackNode;
82 const grid = n.grid;
83 let handles = dEl.el.getAttribute('gs-resize-handles') || grid.opts.resizable.handles || 'e,s,se';
84 if (handles === 'all') handles = 'n,e,s,w,se,sw,ne,nw';
85 // NOTE: keep the resize handles as e,w don't have enough space (10px) to show resize corners anyway. limit during drag instead
86 // restrict vertical resize if height is done to match content anyway... odd to have it spring back
87 // if (Utils.shouldSizeToContent(n, true)) {
88 // const doE = handles.indexOf('e') !== -1;
89 // const doW = handles.indexOf('w') !== -1;
90 // handles = doE ? (doW ? 'e,w' : 'e') : (doW ? 'w' : '');
91 // }
92 const autoHide = !grid.opts.alwaysShowResizeHandle;
93 dEl.setupResizable({
94 ...grid.opts.resizable,
95 ...{ handles, autoHide },
96 ...{
97 start: opts.start,
98 stop: opts.stop,
99 resize: opts.resize,
100 rtl: opts.rtl,
101 }
102 });
103 }
104 });
105 return this;
106 }
107
108 /**
109 * Enable/disable/configure dragging for grid elements.

Callers

nothing calls this directly

Calls 3

_getDDElementsMethod · 0.95
cleanResizableMethod · 0.80
setupResizableMethod · 0.80

Tested by

no test coverage detected