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

Method setupDragIn

src/gridstack.ts:2199–2210  ·  view source on GitHub ↗

* call to setup dragging in from the outside (say toolbar), by specifying the class selection and options. * Called during GridStack.init() as options, but can also be called directly (last param are used) in case the toolbar * is dynamically create and needs to be set later. * @param dragI

(dragIn?: string | HTMLElement[], dragInOptions?: DDDragOpt, widgets?: GridStackWidget[], root: HTMLElement | Document = document)

Source from the content-addressed store, hash-verified

2197 * @param root optional root which defaults to document (for shadow dom pass the parent HTMLDocument)
2198 */
2199 public static setupDragIn(dragIn?: string | HTMLElement[], dragInOptions?: DDDragOpt, widgets?: GridStackWidget[], root: HTMLElement | Document = document): void {
2200 if (dragInOptions?.pause !== undefined) {
2201 DDManager.pauseDrag = dragInOptions.pause;
2202 }
2203
2204 dragInOptions = { appendTo: 'body', helper: 'clone', ...(dragInOptions || {}) }; // default to handle:undefined = drag by the whole item
2205 const els = (typeof dragIn === 'string') ? Utils.getElements(dragIn, root) : dragIn;
2206 els.forEach((el, i) => {
2207 if (!dd.isDraggable(el)) dd.dragIn(el, dragInOptions);
2208 if (widgets?.[i]) (el as GridItemHTMLElement).gridstackNode = widgets[i];
2209 });
2210 }
2211
2212 /**
2213 * Enables/Disables dragging by the user for specific grid elements.

Callers 1

onShowMethod · 0.80

Calls 3

isDraggableMethod · 0.80
dragInMethod · 0.80
getElementsMethod · 0.45

Tested by

no test coverage detected