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

Method _init

src/dd-resizable-handle.ts:37–67  ·  view source on GitHub ↗

@internal

()

Source from the content-addressed store, hash-verified

35
36 /** @internal */
37 protected _init(): DDResizableHandle {
38 if (this.option.element) {
39 try {
40 this.el = this.option.element instanceof HTMLElement
41 ? this.option.element
42 : this.host.querySelector(this.option.element)
43 } catch (error) {
44 this.option.element = undefined // make sure destroy handles it correctly
45 console.error("Query for resizeable handle failed, falling back", error)
46 }
47 }
48
49 if (!this.el) {
50 this.el = document.createElement('div');
51 this.host.appendChild(this.el);
52 }
53
54 this.el.classList.add('ui-resizable-handle');
55 this.el.classList.add(`${DDResizableHandle.prefix}${this.dir}`);
56 this.el.style.zIndex = '100';
57 this.el.style.userSelect = 'none';
58
59 this.el.addEventListener('mousedown', this._mouseDown);
60 if (isTouch) {
61 this.el.addEventListener('touchstart', touchstart);
62 this.el.addEventListener('pointerdown', pointerdown);
63 // this.el.style.touchAction = 'none'; // not needed unlike pointerdown doc comment
64 }
65
66 return this;
67 }
68
69 /** call this when resize handle needs to be removed and cleaned up */
70 public destroy(): DDResizableHandle {

Callers 1

constructorMethod · 0.95

Calls 1

addMethod · 0.45

Tested by

no test coverage detected