gridstack 8.0.0 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/README.md +14 -11
  2. package/dist/dd-base-impl.d.ts +1 -1
  3. package/dist/dd-base-impl.js +1 -1
  4. package/dist/dd-base-impl.js.map +1 -1
  5. package/dist/dd-draggable.d.ts +3 -2
  6. package/dist/dd-draggable.js +10 -9
  7. package/dist/dd-draggable.js.map +1 -1
  8. package/dist/dd-droppable.d.ts +1 -1
  9. package/dist/dd-droppable.js +1 -1
  10. package/dist/dd-droppable.js.map +1 -1
  11. package/dist/dd-element.d.ts +1 -1
  12. package/dist/dd-element.js +1 -1
  13. package/dist/dd-element.js.map +1 -1
  14. package/dist/dd-gridstack.d.ts +1 -1
  15. package/dist/dd-gridstack.js +1 -1
  16. package/dist/dd-gridstack.js.map +1 -1
  17. package/dist/dd-manager.d.ts +1 -1
  18. package/dist/dd-manager.js +1 -1
  19. package/dist/dd-manager.js.map +1 -1
  20. package/dist/dd-resizable-handle.d.ts +1 -1
  21. package/dist/dd-resizable-handle.js +1 -1
  22. package/dist/dd-resizable-handle.js.map +1 -1
  23. package/dist/dd-resizable.d.ts +1 -1
  24. package/dist/dd-resizable.js +1 -1
  25. package/dist/dd-resizable.js.map +1 -1
  26. package/dist/dd-touch.d.ts +1 -1
  27. package/dist/dd-touch.js +1 -1
  28. package/dist/dd-touch.js.map +1 -1
  29. package/dist/es5/dd-base-impl.d.ts +1 -1
  30. package/dist/es5/dd-base-impl.js +1 -1
  31. package/dist/es5/dd-base-impl.js.map +1 -1
  32. package/dist/es5/dd-draggable.d.ts +3 -2
  33. package/dist/es5/dd-draggable.js +10 -9
  34. package/dist/es5/dd-draggable.js.map +1 -1
  35. package/dist/es5/dd-droppable.d.ts +1 -1
  36. package/dist/es5/dd-droppable.js +1 -1
  37. package/dist/es5/dd-droppable.js.map +1 -1
  38. package/dist/es5/dd-element.d.ts +1 -1
  39. package/dist/es5/dd-element.js +1 -1
  40. package/dist/es5/dd-element.js.map +1 -1
  41. package/dist/es5/dd-gridstack.d.ts +1 -1
  42. package/dist/es5/dd-gridstack.js +1 -1
  43. package/dist/es5/dd-gridstack.js.map +1 -1
  44. package/dist/es5/dd-manager.d.ts +1 -1
  45. package/dist/es5/dd-manager.js +1 -1
  46. package/dist/es5/dd-manager.js.map +1 -1
  47. package/dist/es5/dd-resizable-handle.d.ts +1 -1
  48. package/dist/es5/dd-resizable-handle.js +1 -1
  49. package/dist/es5/dd-resizable-handle.js.map +1 -1
  50. package/dist/es5/dd-resizable.d.ts +1 -1
  51. package/dist/es5/dd-resizable.js +1 -1
  52. package/dist/es5/dd-resizable.js.map +1 -1
  53. package/dist/es5/dd-touch.d.ts +1 -1
  54. package/dist/es5/dd-touch.js +1 -1
  55. package/dist/es5/dd-touch.js.map +1 -1
  56. package/dist/es5/gridstack-all.js +1 -1
  57. package/dist/es5/gridstack-all.js.LICENSE.txt +1 -1
  58. package/dist/es5/gridstack-all.js.map +1 -1
  59. package/dist/es5/gridstack-engine.d.ts +1 -1
  60. package/dist/es5/gridstack-engine.js +1 -1
  61. package/dist/es5/gridstack-engine.js.map +1 -1
  62. package/dist/es5/gridstack-poly.js +1 -1
  63. package/dist/es5/gridstack.d.ts +6 -3
  64. package/dist/es5/gridstack.js +18 -25
  65. package/dist/es5/gridstack.js.map +1 -1
  66. package/dist/es5/types.d.ts +5 -3
  67. package/dist/es5/types.js +1 -1
  68. package/dist/es5/types.js.map +1 -1
  69. package/dist/es5/utils.d.ts +6 -6
  70. package/dist/es5/utils.js +31 -20
  71. package/dist/es5/utils.js.map +1 -1
  72. package/dist/gridstack-all.js +1 -1
  73. package/dist/gridstack-all.js.LICENSE.txt +1 -1
  74. package/dist/gridstack-all.js.map +1 -1
  75. package/dist/gridstack-engine.d.ts +1 -1
  76. package/dist/gridstack-engine.js +1 -1
  77. package/dist/gridstack-engine.js.map +1 -1
  78. package/dist/gridstack-extra.css +180 -240
  79. package/dist/gridstack-extra.min.css +1 -1
  80. package/dist/gridstack.css +99 -106
  81. package/dist/gridstack.d.ts +6 -3
  82. package/dist/gridstack.js +16 -25
  83. package/dist/gridstack.js.map +1 -1
  84. package/dist/gridstack.min.css +1 -1
  85. package/dist/ng/gridstack-item.component.d.ts +1 -1
  86. package/dist/ng/gridstack-item.component.js +1 -1
  87. package/dist/ng/gridstack.component.d.ts +1 -1
  88. package/dist/ng/gridstack.component.js +1 -1
  89. package/dist/src/gridstack-extra.scss +9 -11
  90. package/dist/src/gridstack.scss +108 -89
  91. package/dist/types.d.ts +5 -3
  92. package/dist/types.js +1 -1
  93. package/dist/types.js.map +1 -1
  94. package/dist/utils.d.ts +6 -6
  95. package/dist/utils.js +29 -20
  96. package/dist/utils.js.map +1 -1
  97. package/doc/CHANGES.md +15 -0
  98. package/doc/README.md +8 -14
  99. package/package.json +1 -1
  100. package/dist_save/angular/README.md +0 -94
  101. package/dist_save/angular/gridstack-item.component.ts +0 -72
  102. package/dist_save/angular/gridstack.component.ts +0 -199
  103. package/dist_save/dd-base-impl.d.ts +0 -20
  104. package/dist_save/dd-base-impl.js +0 -36
  105. package/dist_save/dd-base-impl.js.map +0 -1
  106. package/dist_save/dd-draggable.d.ts +0 -28
  107. package/dist_save/dd-draggable.js +0 -343
  108. package/dist_save/dd-draggable.js.map +0 -1
  109. package/dist_save/dd-droppable.d.ts +0 -26
  110. package/dist_save/dd-droppable.js +0 -149
  111. package/dist_save/dd-droppable.js.map +0 -1
  112. package/dist_save/dd-element.d.ts +0 -27
  113. package/dist_save/dd-element.js +0 -95
  114. package/dist_save/dd-element.js.map +0 -1
  115. package/dist_save/dd-gridstack.d.ts +0 -34
  116. package/dist_save/dd-gridstack.js +0 -125
  117. package/dist_save/dd-gridstack.js.map +0 -1
  118. package/dist_save/dd-manager.d.ts +0 -22
  119. package/dist_save/dd-manager.js +0 -14
  120. package/dist_save/dd-manager.js.map +0 -1
  121. package/dist_save/dd-resizable-handle.d.ts +0 -14
  122. package/dist_save/dd-resizable-handle.js +0 -106
  123. package/dist_save/dd-resizable-handle.js.map +0 -1
  124. package/dist_save/dd-resizable.d.ts +0 -28
  125. package/dist_save/dd-resizable.js +0 -294
  126. package/dist_save/dd-resizable.js.map +0 -1
  127. package/dist_save/dd-touch.d.ts +0 -33
  128. package/dist_save/dd-touch.js +0 -183
  129. package/dist_save/dd-touch.js.map +0 -1
  130. package/dist_save/es5/dd-base-impl.d.ts +0 -20
  131. package/dist_save/es5/dd-base-impl.js +0 -41
  132. package/dist_save/es5/dd-base-impl.js.map +0 -1
  133. package/dist_save/es5/dd-draggable.d.ts +0 -28
  134. package/dist_save/es5/dd-draggable.js +0 -366
  135. package/dist_save/es5/dd-draggable.js.map +0 -1
  136. package/dist_save/es5/dd-droppable.d.ts +0 -26
  137. package/dist_save/es5/dd-droppable.js +0 -180
  138. package/dist_save/es5/dd-droppable.js.map +0 -1
  139. package/dist_save/es5/dd-element.d.ts +0 -27
  140. package/dist_save/es5/dd-element.js +0 -96
  141. package/dist_save/es5/dd-element.js.map +0 -1
  142. package/dist_save/es5/dd-gridstack.d.ts +0 -34
  143. package/dist_save/es5/dd-gridstack.js +0 -145
  144. package/dist_save/es5/dd-gridstack.js.map +0 -1
  145. package/dist_save/es5/dd-manager.d.ts +0 -22
  146. package/dist_save/es5/dd-manager.js +0 -17
  147. package/dist_save/es5/dd-manager.js.map +0 -1
  148. package/dist_save/es5/dd-resizable-handle.d.ts +0 -14
  149. package/dist_save/es5/dd-resizable-handle.js +0 -107
  150. package/dist_save/es5/dd-resizable-handle.js.map +0 -1
  151. package/dist_save/es5/dd-resizable.d.ts +0 -28
  152. package/dist_save/es5/dd-resizable.js +0 -316
  153. package/dist_save/es5/dd-resizable.js.map +0 -1
  154. package/dist_save/es5/dd-touch.d.ts +0 -33
  155. package/dist_save/es5/dd-touch.js +0 -186
  156. package/dist_save/es5/dd-touch.js.map +0 -1
  157. package/dist_save/es5/gridstack-all.js +0 -3
  158. package/dist_save/es5/gridstack-all.js.LICENSE.txt +0 -7
  159. package/dist_save/es5/gridstack-all.js.map +0 -1
  160. package/dist_save/es5/gridstack-engine.d.ts +0 -102
  161. package/dist_save/es5/gridstack-engine.js +0 -997
  162. package/dist_save/es5/gridstack-engine.js.map +0 -1
  163. package/dist_save/es5/gridstack-poly.js +0 -356
  164. package/dist_save/es5/gridstack.d.ts +0 -376
  165. package/dist_save/es5/gridstack.js +0 -2238
  166. package/dist_save/es5/gridstack.js.map +0 -1
  167. package/dist_save/es5/types.d.ts +0 -284
  168. package/dist_save/es5/types.js +0 -36
  169. package/dist_save/es5/types.js.map +0 -1
  170. package/dist_save/es5/utils.d.ts +0 -95
  171. package/dist_save/es5/utils.js +0 -590
  172. package/dist_save/es5/utils.js.map +0 -1
  173. package/dist_save/gridstack-all.js +0 -3
  174. package/dist_save/gridstack-all.js.LICENSE.txt +0 -7
  175. package/dist_save/gridstack-all.js.map +0 -1
  176. package/dist_save/gridstack-engine.d.ts +0 -102
  177. package/dist_save/gridstack-engine.js +0 -956
  178. package/dist_save/gridstack-engine.js.map +0 -1
  179. package/dist_save/gridstack-extra.css +0 -433
  180. package/dist_save/gridstack-extra.min.css +0 -1
  181. package/dist_save/gridstack.css +0 -226
  182. package/dist_save/gridstack.d.ts +0 -376
  183. package/dist_save/gridstack.js +0 -2162
  184. package/dist_save/gridstack.js.map +0 -1
  185. package/dist_save/gridstack.min.css +0 -1
  186. package/dist_save/src/gridstack-extra.scss +0 -27
  187. package/dist_save/src/gridstack.scss +0 -131
  188. package/dist_save/types.d.ts +0 -284
  189. package/dist_save/types.js +0 -36
  190. package/dist_save/types.js.map +0 -1
  191. package/dist_save/utils.d.ts +0 -95
  192. package/dist_save/utils.js +0 -548
  193. package/dist_save/utils.js.map +0 -1
@@ -1,183 +0,0 @@
1
- "use strict";
2
- /**
3
- * touch.ts 7.3.0-dev
4
- * Copyright (c) 2021 Alain Dumesny - see GridStack root license
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.pointerleave = exports.pointerenter = exports.pointerdown = exports.touchend = exports.touchmove = exports.touchstart = exports.isTouch = void 0;
8
- const dd_manager_1 = require("./dd-manager");
9
- /**
10
- * Detect touch support - Windows Surface devices and other touch devices
11
- * should we use this instead ? (what we had for always showing resize handles)
12
- * /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
13
- */
14
- exports.isTouch = typeof window !== 'undefined' && typeof document !== 'undefined' &&
15
- ('ontouchstart' in document
16
- || 'ontouchstart' in window
17
- // || !!window.TouchEvent // true on Windows 10 Chrome desktop so don't use this
18
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
- || (window.DocumentTouch && document instanceof window.DocumentTouch)
20
- || navigator.maxTouchPoints > 0
21
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
- || navigator.msMaxTouchPoints > 0);
23
- // interface TouchCoord {x: number, y: number};
24
- class DDTouch {
25
- }
26
- /**
27
- * Get the x,y position of a touch event
28
- */
29
- // function getTouchCoords(e: TouchEvent): TouchCoord {
30
- // return {
31
- // x: e.changedTouches[0].pageX,
32
- // y: e.changedTouches[0].pageY
33
- // };
34
- // }
35
- /**
36
- * Simulate a mouse event based on a corresponding touch event
37
- * @param {Object} e A touch event
38
- * @param {String} simulatedType The corresponding mouse event
39
- */
40
- function simulateMouseEvent(e, simulatedType) {
41
- // Ignore multi-touch events
42
- if (e.touches.length > 1)
43
- return;
44
- // Prevent "Ignored attempt to cancel a touchmove event with cancelable=false" errors
45
- if (e.cancelable)
46
- e.preventDefault();
47
- const touch = e.changedTouches[0], simulatedEvent = document.createEvent('MouseEvents');
48
- // Initialize the simulated mouse event using the touch event's coordinates
49
- simulatedEvent.initMouseEvent(simulatedType, // type
50
- true, // bubbles
51
- true, // cancelable
52
- window, // view
53
- 1, // detail
54
- touch.screenX, // screenX
55
- touch.screenY, // screenY
56
- touch.clientX, // clientX
57
- touch.clientY, // clientY
58
- false, // ctrlKey
59
- false, // altKey
60
- false, // shiftKey
61
- false, // metaKey
62
- 0, // button
63
- null // relatedTarget
64
- );
65
- // Dispatch the simulated event to the target element
66
- e.target.dispatchEvent(simulatedEvent);
67
- }
68
- /**
69
- * Simulate a mouse event based on a corresponding Pointer event
70
- * @param {Object} e A pointer event
71
- * @param {String} simulatedType The corresponding mouse event
72
- */
73
- function simulatePointerMouseEvent(e, simulatedType) {
74
- // Prevent "Ignored attempt to cancel a touchmove event with cancelable=false" errors
75
- if (e.cancelable)
76
- e.preventDefault();
77
- const simulatedEvent = document.createEvent('MouseEvents');
78
- // Initialize the simulated mouse event using the touch event's coordinates
79
- simulatedEvent.initMouseEvent(simulatedType, // type
80
- true, // bubbles
81
- true, // cancelable
82
- window, // view
83
- 1, // detail
84
- e.screenX, // screenX
85
- e.screenY, // screenY
86
- e.clientX, // clientX
87
- e.clientY, // clientY
88
- false, // ctrlKey
89
- false, // altKey
90
- false, // shiftKey
91
- false, // metaKey
92
- 0, // button
93
- null // relatedTarget
94
- );
95
- // Dispatch the simulated event to the target element
96
- e.target.dispatchEvent(simulatedEvent);
97
- }
98
- /**
99
- * Handle the touchstart events
100
- * @param {Object} e The widget element's touchstart event
101
- */
102
- function touchstart(e) {
103
- // Ignore the event if another widget is already being handled
104
- if (DDTouch.touchHandled)
105
- return;
106
- DDTouch.touchHandled = true;
107
- // Simulate the mouse events
108
- // simulateMouseEvent(e, 'mouseover');
109
- // simulateMouseEvent(e, 'mousemove');
110
- simulateMouseEvent(e, 'mousedown');
111
- }
112
- exports.touchstart = touchstart;
113
- /**
114
- * Handle the touchmove events
115
- * @param {Object} e The document's touchmove event
116
- */
117
- function touchmove(e) {
118
- // Ignore event if not handled by us
119
- if (!DDTouch.touchHandled)
120
- return;
121
- simulateMouseEvent(e, 'mousemove');
122
- }
123
- exports.touchmove = touchmove;
124
- /**
125
- * Handle the touchend events
126
- * @param {Object} e The document's touchend event
127
- */
128
- function touchend(e) {
129
- // Ignore event if not handled
130
- if (!DDTouch.touchHandled)
131
- return;
132
- // cancel delayed leave event when we release on ourself which happens BEFORE we get this!
133
- if (DDTouch.pointerLeaveTimeout) {
134
- window.clearTimeout(DDTouch.pointerLeaveTimeout);
135
- delete DDTouch.pointerLeaveTimeout;
136
- }
137
- const wasDragging = !!dd_manager_1.DDManager.dragElement;
138
- // Simulate the mouseup event
139
- simulateMouseEvent(e, 'mouseup');
140
- // simulateMouseEvent(event, 'mouseout');
141
- // If the touch interaction did not move, it should trigger a click
142
- if (!wasDragging) {
143
- simulateMouseEvent(e, 'click');
144
- }
145
- // Unset the flag to allow other widgets to inherit the touch event
146
- DDTouch.touchHandled = false;
147
- }
148
- exports.touchend = touchend;
149
- /**
150
- * Note we don't get touchenter/touchleave (which are deprecated)
151
- * see https://stackoverflow.com/questions/27908339/js-touch-equivalent-for-mouseenter
152
- * so instead of PointerEvent to still get enter/leave and send the matching mouse event.
153
- */
154
- function pointerdown(e) {
155
- // console.log("pointer down")
156
- e.target.releasePointerCapture(e.pointerId); // <- Important!
157
- }
158
- exports.pointerdown = pointerdown;
159
- function pointerenter(e) {
160
- // ignore the initial one we get on pointerdown on ourself
161
- if (!dd_manager_1.DDManager.dragElement) {
162
- // console.log('pointerenter ignored');
163
- return;
164
- }
165
- // console.log('pointerenter');
166
- simulatePointerMouseEvent(e, 'mouseenter');
167
- }
168
- exports.pointerenter = pointerenter;
169
- function pointerleave(e) {
170
- // ignore the leave on ourself we get before releasing the mouse over ourself
171
- // by delaying sending the event and having the up event cancel us
172
- if (!dd_manager_1.DDManager.dragElement) {
173
- // console.log('pointerleave ignored');
174
- return;
175
- }
176
- DDTouch.pointerLeaveTimeout = window.setTimeout(() => {
177
- delete DDTouch.pointerLeaveTimeout;
178
- // console.log('pointerleave delayed');
179
- simulatePointerMouseEvent(e, 'mouseleave');
180
- }, 10);
181
- }
182
- exports.pointerleave = pointerleave;
183
- //# sourceMappingURL=dd-touch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dd-touch.js","sourceRo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AY,CAAC,CAAe;IAC1C,6EAA6E;IAC7E,kEAAkE;IAClE,IAAI,CAAC,sBAAS,CAAC,WAAW,EAAE;QAC1B,uCAAuC;QACvC,OAAO;KACR;IACD,OAAO,CAAC,mBAAmB,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE;QACnD,OAAO,OAAO,CAAC,mBAAmB,CAAC;QACnC,uCAAuC;QACvC,yBAAyB,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAC7C,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAZD,oCAYC","sourcesContent":["/**\n * touch.ts 7.3.0-dev\n * Copyright (c) 2021 Alain Dumesny - see GridStack root license\n */\n\nimport { DDManager } from './dd-manager';\n\n/**\n * Detect touch support - Windows Surface devices and other touch devices\n * should we use this instead ? (what we had for always showing resize handles)\n * /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)\n */\nexport const isTouch: boolean = typeof window !== 'undefined' && typeof document !== 'undefined' &&\n( 'ontouchstart' in document\n || 'ontouchstart' in window\n // || !!window.TouchEvent // true on Windows 10 Chrome desktop so don't use this\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n || ((window as any).DocumentTouch && document instanceof (window as any).DocumentTouch)\n || navigator.maxTouchPoints > 0\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n || (navigator as any).msMaxTouchPoints > 0\n);\n\n// interface TouchCoord {x: number, y: number};\n\nclass DDTouch {\n public static touchHandled: boolean;\n public static pointerLeaveTimeout: number;\n}\n\n/**\n* Get the x,y position of a touch event\n*/\n// function getTouchCoords(e: TouchEvent): TouchCoord {\n// return {\n// x: e.changedTouches[0].pageX,\n// y: e.changedTouches[0].pageY\n// };\n// }\n\n/**\n * Simulate a mouse event based on a corresponding touch event\n * @param {Object} e A touch event\n * @param {String} simulatedType The corresponding mouse event\n */\nfunction simulateMouseEvent(e: TouchEvent, simulatedType: string) {\n\n // Ignore multi-touch events\n if (e.touches.length > 1) return;\n\n // Prevent \"Ignored attempt to cancel a touchmove event with cancelable=false\" errors\n if (e.cancelable) e.preventDefault();\n\n const touch = e.changedTouches[0], simulatedEvent = document.createEvent('MouseEvents');\n\n // Initialize the simulated mouse event using the touch event's coordinates\n simulatedEvent.initMouseEvent(\n simulatedType, // type\n true, // bubbles\n true, // cancelable\n window, // view\n 1, // detail\n touch.screenX, // screenX\n touch.screenY, // screenY\n touch.clientX, // clientX\n touch.clientY, // clientY\n false, // ctrlKey\n false, // altKey\n false, // shiftKey\n false, // metaKey\n 0, // button\n null // relatedTarget\n );\n\n // Dispatch the simulated event to the target element\n e.target.dispatchEvent(simulatedEvent);\n}\n\n/**\n * Simulate a mouse event based on a corresponding Pointer event\n * @param {Object} e A pointer event\n * @param {String} simulatedType The corresponding mouse event\n */\nfunction simulatePointerMouseEvent(e: PointerEvent, simulatedType: string) {\n\n // Prevent \"Ignored attempt to cancel a touchmove event with cancelable=false\" errors\n if (e.cancelable) e.preventDefault();\n\n const simulatedEvent = document.createEvent('MouseEvents');\n\n // Initialize the simulated mouse event using the touch event's coordinates\n simulatedEvent.initMouseEvent(\n simulatedType, // type\n true, // bubbles\n true, // cancelable\n window, // view\n 1, // detail\n e.screenX, // screenX\n e.screenY, // screenY\n e.clientX, // clientX\n e.clientY, // clientY\n false, // ctrlKey\n false, // altKey\n false, // shiftKey\n false, // metaKey\n 0, // button\n null // relatedTarget\n );\n\n // Dispatch the simulated event to the target element\n e.target.dispatchEvent(simulatedEvent);\n}\n\n\n/**\n * Handle the touchstart events\n * @param {Object} e The widget element's touchstart event\n */\nexport function touchstart(e: TouchEvent): void {\n // Ignore the event if another widget is already being handled\n if (DDTouch.touchHandled) return;\n DDTouch.touchHandled = true;\n\n // Simulate the mouse events\n // simulateMouseEvent(e, 'mouseover');\n // simulateMouseEvent(e, 'mousemove');\n simulateMouseEvent(e, 'mousedown');\n}\n\n/**\n * Handle the touchmove events\n * @param {Object} e The document's touchmove event\n */\nexport function touchmove(e: TouchEvent): void {\n // Ignore event if not handled by us\n if (!DDTouch.touchHandled) return;\n\n simulateMouseEvent(e, 'mousemove');\n}\n\n/**\n * Handle the touchend events\n * @param {Object} e The document's touchend event\n */\nexport function touchend(e: TouchEvent): void {\n\n // Ignore event if not handled\n if (!DDTouch.touchHandled) return;\n\n // cancel delayed leave event when we release on ourself which happens BEFORE we get this!\n if (DDTouch.pointerLeaveTimeout) {\n window.clearTimeout(DDTouch.pointerLeaveTimeout);\n delete DDTouch.pointerLeaveTimeout;\n }\n\n const wasDragging = !!DDManager.dragElement;\n\n // Simulate the mouseup event\n simulateMouseEvent(e, 'mouseup');\n // simulateMouseEvent(event, 'mouseout');\n\n // If the touch interaction did not move, it should trigger a click\n if (!wasDragging) {\n simulateMouseEvent(e, 'click');\n }\n\n // Unset the flag to allow other widgets to inherit the touch event\n DDTouch.touchHandled = false;\n}\n\n/**\n * Note we don't get touchenter/touchleave (which are deprecated)\n * see https://stackoverflow.com/questions/27908339/js-touch-equivalent-for-mouseenter\n * so instead of PointerEvent to still get enter/leave and send the matching mouse event.\n */\nexport function pointerdown(e: PointerEvent): void {\n // console.log(\"pointer down\")\n (e.target as HTMLElement).releasePointerCapture(e.pointerId) // <- Important!\n}\n\nexport function pointerenter(e: PointerEvent): void {\n // ignore the initial one we get on pointerdown on ourself\n if (!DDManager.dragElement) {\n // console.log('pointerenter ignored');\n return;\n }\n // console.log('pointerenter');\n simulatePointerMouseEvent(e, 'mouseenter');\n}\n\nexport function pointerleave(e: PointerEvent): void {\n // ignore the leave on ourself we get before releasing the mouse over ourself\n // by delaying sending the event and having the up event cancel us\n if (!DDManager.dragElement) {\n // console.log('pointerleave ignored');\n return;\n }\n DDTouch.pointerLeaveTimeout = window.setTimeout(() => {\n delete DDTouch.pointerLeaveTimeout;\n // console.log('pointerleave delayed');\n simulatePointerMouseEvent(e, 'mouseleave');\n }, 10);\n}\n\n"]}
@@ -1,20 +0,0 @@
1
- /**
2
- * dd-base-impl.ts 7.3.0-dev
3
- * Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license
4
- */
5
- export declare type EventCallback = (event: Event) => boolean | void;
6
- export declare abstract class DDBaseImplement {
7
- /** returns the enable state, but you have to call enable()/disable() to change (as other things need to happen) */
8
- get disabled(): boolean;
9
- on(event: string, callback: EventCallback): void;
10
- off(event: string): void;
11
- enable(): void;
12
- disable(): void;
13
- destroy(): void;
14
- triggerEvent(eventName: string, event: Event): boolean | void;
15
- }
16
- export interface HTMLElementExtendOpt<T> {
17
- el: HTMLElement;
18
- option: T;
19
- updateOption(T: any): DDBaseImplement;
20
- }
@@ -1,41 +0,0 @@
1
- "use strict";
2
- /**
3
- * dd-base-impl.ts 7.3.0-dev
4
- * Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.DDBaseImplement = void 0;
8
- var DDBaseImplement = /** @class */ (function () {
9
- function DDBaseImplement() {
10
- /** @internal */
11
- this._eventRegister = {};
12
- }
13
- Object.defineProperty(DDBaseImplement.prototype, "disabled", {
14
- /** returns the enable state, but you have to call enable()/disable() to change (as other things need to happen) */
15
- get: function () { return this._disabled; },
16
- enumerable: false,
17
- configurable: true
18
- });
19
- DDBaseImplement.prototype.on = function (event, callback) {
20
- this._eventRegister[event] = callback;
21
- };
22
- DDBaseImplement.prototype.off = function (event) {
23
- delete this._eventRegister[event];
24
- };
25
- DDBaseImplement.prototype.enable = function () {
26
- this._disabled = false;
27
- };
28
- DDBaseImplement.prototype.disable = function () {
29
- this._disabled = true;
30
- };
31
- DDBaseImplement.prototype.destroy = function () {
32
- delete this._eventRegister;
33
- };
34
- DDBaseImplement.prototype.triggerEvent = function (eventName, event) {
35
- if (!this.disabled && this._eventRegister && this._eventRegister[eventName])
36
- return this._eventRegister[eventName](event);
37
- };
38
- return DDBaseImplement;
39
- }());
40
- exports.DDBaseImplement = DDBaseImplement;
41
- //# sourceMappingURL=dd-base-impl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dd-base-impl.js","sourceRoot":"","sources":["../../src/dd-base-impl.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH;IAAA;QAME,gBAAgB;QACN,mBAAc,GAEpB,EAAE,CAAC;IA0BT,CAAC;IAjCC,sBAAW,qCAAQ;QADnB,mHAAmH;aACnH,cAAmC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;;;OAAA;IASpD,4BAAE,GAAT,UAAU,KAAa,EAAE,QAAuB;QAC9C,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC;IACxC,CAAC;IAEM,6BAAG,GAAV,UAAW,KAAa;QACtB,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAEM,gCAAM,GAAb;QACE,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;IAEM,iCAAO,GAAd;QACE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAEM,iCAAO,GAAd;QACE,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAEM,sCAAY,GAAnB,UAAoB,SAAiB,EAAE,KAAY;QACjD,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC;YACzE,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;IACH,sBAAC;AAAD,CAAC,AAnCD,IAmCC;AAnCqB,0CAAe","sourcesContent":["/**\n * dd-base-impl.ts 7.3.0-dev\n * Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license\n */\n\nexport type EventCallback = (event: Event) => boolean|void;\nexport abstract class DDBaseImplement {\n /** returns the enable state, but you have to call enable()/disable() to change (as other things need to happen) */\n public get disabled(): boolean { return this._disabled; }\n\n /** @internal */\n protected _disabled: boolean; // initial state to differentiate from false\n /** @internal */\n protected _eventRegister: {\n [eventName: string]: EventCallback;\n } = {};\n\n public on(event: string, callback: EventCallback): void {\n this._eventRegister[event] = callback;\n }\n\n public off(event: string): void {\n delete this._eventRegister[event];\n }\n\n public enable(): void {\n this._disabled = false;\n }\n\n public disable(): void {\n this._disabled = true;\n }\n\n public destroy(): void {\n delete this._eventRegister;\n }\n\n public triggerEvent(eventName: string, event: Event): boolean|void {\n if (!this.disabled && this._eventRegister && this._eventRegister[eventName])\n return this._eventRegister[eventName](event);\n }\n}\n\nexport interface HTMLElementExtendOpt<T> {\n el: HTMLElement;\n option: T;\n updateOption(T): DDBaseImplement;\n}\n"]}
@@ -1,28 +0,0 @@
1
- /**
2
- * dd-draggable.ts 7.3.0-dev
3
- * Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license
4
- */
5
- import { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';
6
- import { DDUIData } from './types';
7
- export interface DDDraggableOpt {
8
- appendTo?: string | HTMLElement;
9
- handle?: string;
10
- helper?: string | HTMLElement | ((event: Event) => HTMLElement);
11
- start?: (event: Event, ui: DDUIData) => void;
12
- stop?: (event: Event) => void;
13
- drag?: (event: Event, ui: DDUIData) => void;
14
- }
15
- declare type DDDragEvent = 'drag' | 'dragstart' | 'dragstop';
16
- export declare class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt<DDDraggableOpt> {
17
- el: HTMLElement;
18
- option: DDDraggableOpt;
19
- helper: HTMLElement;
20
- constructor(el: HTMLElement, option?: DDDraggableOpt);
21
- on(event: DDDragEvent, callback: (event: DragEvent) => void): void;
22
- off(event: DDDragEvent): void;
23
- enable(): void;
24
- disable(forDestroy?: boolean): void;
25
- destroy(): void;
26
- updateOption(opts: DDDraggableOpt): DDDraggable;
27
- }
28
- export {};
@@ -1,366 +0,0 @@
1
- "use strict";
2
- /**
3
- * dd-draggable.ts 7.3.0-dev
4
- * Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license
5
- */
6
- var __extends = (this && this.__extends) || (function () {
7
- var extendStatics = function (d, b) {
8
- extendStatics = Object.setPrototypeOf ||
9
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11
- return extendStatics(d, b);
12
- };
13
- return function (d, b) {
14
- extendStatics(d, b);
15
- function __() { this.constructor = d; }
16
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17
- };
18
- })();
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.DDDraggable = void 0;
21
- var dd_manager_1 = require("./dd-manager");
22
- var utils_1 = require("./utils");
23
- var dd_base_impl_1 = require("./dd-base-impl");
24
- var dd_touch_1 = require("./dd-touch");
25
- // let count = 0; // TEST
26
- var DDDraggable = /** @class */ (function (_super) {
27
- __extends(DDDraggable, _super);
28
- function DDDraggable(el, option) {
29
- if (option === void 0) { option = {}; }
30
- var _this = _super.call(this) || this;
31
- _this.el = el;
32
- _this.option = option;
33
- // get the element that is actually supposed to be dragged by
34
- var handleName = option.handle.substring(1);
35
- _this.dragEl = el.classList.contains(handleName) ? el : el.querySelector(option.handle) || el;
36
- // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)
37
- _this._mouseDown = _this._mouseDown.bind(_this);
38
- _this._mouseMove = _this._mouseMove.bind(_this);
39
- _this._mouseUp = _this._mouseUp.bind(_this);
40
- _this.enable();
41
- return _this;
42
- }
43
- DDDraggable.prototype.on = function (event, callback) {
44
- _super.prototype.on.call(this, event, callback);
45
- };
46
- DDDraggable.prototype.off = function (event) {
47
- _super.prototype.off.call(this, event);
48
- };
49
- DDDraggable.prototype.enable = function () {
50
- if (this.disabled === false)
51
- return;
52
- _super.prototype.enable.call(this);
53
- this.dragEl.addEventListener('mousedown', this._mouseDown);
54
- if (dd_touch_1.isTouch) {
55
- this.dragEl.addEventListener('touchstart', dd_touch_1.touchstart);
56
- this.dragEl.addEventListener('pointerdown', dd_touch_1.pointerdown);
57
- // this.dragEl.style.touchAction = 'none'; // not needed unlike pointerdown doc comment
58
- }
59
- this.el.classList.remove('ui-draggable-disabled');
60
- };
61
- DDDraggable.prototype.disable = function (forDestroy) {
62
- if (forDestroy === void 0) { forDestroy = false; }
63
- if (this.disabled === true)
64
- return;
65
- _super.prototype.disable.call(this);
66
- this.dragEl.removeEventListener('mousedown', this._mouseDown);
67
- if (dd_touch_1.isTouch) {
68
- this.dragEl.removeEventListener('touchstart', dd_touch_1.touchstart);
69
- this.dragEl.removeEventListener('pointerdown', dd_touch_1.pointerdown);
70
- }
71
- if (!forDestroy)
72
- this.el.classList.add('ui-draggable-disabled');
73
- };
74
- DDDraggable.prototype.destroy = function () {
75
- if (this.dragTimeout)
76
- window.clearTimeout(this.dragTimeout);
77
- delete this.dragTimeout;
78
- if (this.dragging)
79
- this._mouseUp(this.mouseDownEvent);
80
- this.disable(true);
81
- delete this.el;
82
- delete this.helper;
83
- delete this.option;
84
- _super.prototype.destroy.call(this);
85
- };
86
- DDDraggable.prototype.updateOption = function (opts) {
87
- var _this = this;
88
- Object.keys(opts).forEach(function (key) { return _this.option[key] = opts[key]; });
89
- return this;
90
- };
91
- /** @internal call when mouse goes down before a dragstart happens */
92
- DDDraggable.prototype._mouseDown = function (e) {
93
- // don't let more than one widget handle mouseStart
94
- if (dd_manager_1.DDManager.mouseHandled)
95
- return;
96
- if (e.button !== 0)
97
- return true; // only left click
98
- // make sure we are not clicking on known object that handles mouseDown (TODO: make this extensible ?) #2054
99
- var skipMouseDown = ['input', 'textarea', 'button', 'select', 'option'];
100
- var name = e.target.nodeName.toLowerCase();
101
- if (skipMouseDown.find(function (skip) { return skip === name; }))
102
- return true;
103
- // also check for content editable
104
- if (e.target.closest('[contenteditable="true"]'))
105
- return true;
106
- // REMOVE: why would we get the event if it wasn't for us or child ?
107
- // make sure we are clicking on a drag handle or child of it...
108
- // Note: we don't need to check that's handle is an immediate child, as mouseHandled will prevent parents from also handling it (lowest wins)
109
- // let className = this.option.handle.substring(1);
110
- // let el = e.target as HTMLElement;
111
- // while (el && !el.classList.contains(className)) { el = el.parentElement; }
112
- // if (!el) return;
113
- this.mouseDownEvent = e;
114
- delete this.dragging;
115
- delete dd_manager_1.DDManager.dragElement;
116
- delete dd_manager_1.DDManager.dropElement;
117
- // document handler so we can continue receiving moves as the item is 'fixed' position, and capture=true so WE get a first crack
118
- document.addEventListener('mousemove', this._mouseMove, true); // true=capture, not bubble
119
- document.addEventListener('mouseup', this._mouseUp, true);
120
- if (dd_touch_1.isTouch) {
121
- this.dragEl.addEventListener('touchmove', dd_touch_1.touchmove);
122
- this.dragEl.addEventListener('touchend', dd_touch_1.touchend);
123
- }
124
- e.preventDefault();
125
- // preventDefault() prevents blur event which occurs just after mousedown event.
126
- // if an editable content has focus, then blur must be call
127
- if (document.activeElement)
128
- document.activeElement.blur();
129
- dd_manager_1.DDManager.mouseHandled = true;
130
- return true;
131
- };
132
- /** @internal method to call actual drag event */
133
- DDDraggable.prototype._callDrag = function (e) {
134
- if (!this.dragging)
135
- return;
136
- var ev = utils_1.Utils.initEvent(e, { target: this.el, type: 'drag' });
137
- if (this.option.drag) {
138
- this.option.drag(ev, this.ui());
139
- }
140
- this.triggerEvent('drag', ev);
141
- };
142
- /** @internal called when the main page (after successful mousedown) receives a move event to drag the item around the screen */
143
- DDDraggable.prototype._mouseMove = function (e) {
144
- var _this = this;
145
- var _a;
146
- // console.log(`${count++} move ${e.x},${e.y}`)
147
- var s = this.mouseDownEvent;
148
- if (this.dragging) {
149
- this._dragFollow(e);
150
- // delay actual grid handling drag until we pause for a while if set
151
- if (dd_manager_1.DDManager.pauseDrag) {
152
- var pause = Number.isInteger(dd_manager_1.DDManager.pauseDrag) ? dd_manager_1.DDManager.pauseDrag : 100;
153
- if (this.dragTimeout)
154
- window.clearTimeout(this.dragTimeout);
155
- this.dragTimeout = window.setTimeout(function () { return _this._callDrag(e); }, pause);
156
- }
157
- else {
158
- this._callDrag(e);
159
- }
160
- }
161
- else if (Math.abs(e.x - s.x) + Math.abs(e.y - s.y) > 3) {
162
- /**
163
- * don't start unless we've moved at least 3 pixels
164
- */
165
- this.dragging = true;
166
- dd_manager_1.DDManager.dragElement = this;
167
- // if we're dragging an actual grid item, set the current drop as the grid (to detect enter/leave)
168
- var grid = (_a = this.el.gridstackNode) === null || _a === void 0 ? void 0 : _a.grid;
169
- if (grid) {
170
- dd_manager_1.DDManager.dropElement = grid.el.ddElement.ddDroppable;
171
- }
172
- else {
173
- delete dd_manager_1.DDManager.dropElement;
174
- }
175
- this.helper = this._createHelper(e);
176
- this._setupHelperContainmentStyle();
177
- this.dragOffset = this._getDragOffset(e, this.el, this.helperContainment);
178
- var ev = utils_1.Utils.initEvent(e, { target: this.el, type: 'dragstart' });
179
- this._setupHelperStyle(e);
180
- if (this.option.start) {
181
- this.option.start(ev, this.ui());
182
- }
183
- this.triggerEvent('dragstart', ev);
184
- }
185
- e.preventDefault(); // needed otherwise we get text sweep text selection as we drag around
186
- return true;
187
- };
188
- /** @internal call when the mouse gets released to drop the item at current location */
189
- DDDraggable.prototype._mouseUp = function (e) {
190
- var _a;
191
- document.removeEventListener('mousemove', this._mouseMove, true);
192
- document.removeEventListener('mouseup', this._mouseUp, true);
193
- if (dd_touch_1.isTouch) {
194
- this.dragEl.removeEventListener('touchmove', dd_touch_1.touchmove, true);
195
- this.dragEl.removeEventListener('touchend', dd_touch_1.touchend, true);
196
- }
197
- if (this.dragging) {
198
- delete this.dragging;
199
- // reset the drop target if dragging over ourself (already parented, just moving during stop callback below)
200
- if (((_a = dd_manager_1.DDManager.dropElement) === null || _a === void 0 ? void 0 : _a.el) === this.el.parentElement) {
201
- delete dd_manager_1.DDManager.dropElement;
202
- }
203
- this.helperContainment.style.position = this.parentOriginStylePosition || null;
204
- if (this.helper === this.el) {
205
- this._removeHelperStyle();
206
- }
207
- else {
208
- this.helper.remove();
209
- }
210
- var ev = utils_1.Utils.initEvent(e, { target: this.el, type: 'dragstop' });
211
- if (this.option.stop) {
212
- this.option.stop(ev); // NOTE: destroy() will be called when removing item, so expect NULL ptr after!
213
- }
214
- this.triggerEvent('dragstop', ev);
215
- // call the droppable method to receive the item
216
- if (dd_manager_1.DDManager.dropElement) {
217
- dd_manager_1.DDManager.dropElement.drop(e);
218
- }
219
- }
220
- delete this.helper;
221
- delete this.mouseDownEvent;
222
- delete dd_manager_1.DDManager.dragElement;
223
- delete dd_manager_1.DDManager.dropElement;
224
- delete dd_manager_1.DDManager.mouseHandled;
225
- e.preventDefault();
226
- };
227
- /** @internal create a clone copy (or user defined method) of the original drag item if set */
228
- DDDraggable.prototype._createHelper = function (event) {
229
- var _this = this;
230
- var helper = this.el;
231
- if (typeof this.option.helper === 'function') {
232
- helper = this.option.helper(event);
233
- }
234
- else if (this.option.helper === 'clone') {
235
- helper = utils_1.Utils.cloneNode(this.el);
236
- }
237
- if (!document.body.contains(helper)) {
238
- utils_1.Utils.appendTo(helper, this.option.appendTo === 'parent' ? this.el.parentNode : this.option.appendTo);
239
- }
240
- if (helper === this.el) {
241
- this.dragElementOriginStyle = DDDraggable.originStyleProp.map(function (prop) { return _this.el.style[prop]; });
242
- }
243
- return helper;
244
- };
245
- /** @internal set the fix position of the dragged item */
246
- DDDraggable.prototype._setupHelperStyle = function (e) {
247
- var _this = this;
248
- this.helper.classList.add('ui-draggable-dragging');
249
- // TODO: set all at once with style.cssText += ... ? https://stackoverflow.com/questions/3968593
250
- var style = this.helper.style;
251
- style.pointerEvents = 'none'; // needed for over items to get enter/leave
252
- // style.cursor = 'move'; // TODO: can't set with pointerEvents=none ! (done in CSS as well)
253
- style['min-width'] = 0; // since we no longer relative to our parent and we don't resize anyway (normally 100/#column %)
254
- style.width = this.dragOffset.width + 'px';
255
- style.height = this.dragOffset.height + 'px';
256
- style.willChange = 'left, top';
257
- style.position = 'fixed'; // let us drag between grids by not clipping as parent .grid-stack is position: 'relative'
258
- this._dragFollow(e); // now position it
259
- style.transition = 'none'; // show up instantly
260
- setTimeout(function () {
261
- if (_this.helper) {
262
- style.transition = null; // recover animation
263
- }
264
- }, 0);
265
- return this;
266
- };
267
- /** @internal restore back the original style before dragging */
268
- DDDraggable.prototype._removeHelperStyle = function () {
269
- var _this = this;
270
- var _a;
271
- this.helper.classList.remove('ui-draggable-dragging');
272
- var node = (_a = this.helper) === null || _a === void 0 ? void 0 : _a.gridstackNode;
273
- // don't bother restoring styles if we're gonna remove anyway...
274
- if (!(node === null || node === void 0 ? void 0 : node._isAboutToRemove) && this.dragElementOriginStyle) {
275
- var helper_1 = this.helper;
276
- // don't animate, otherwise we animate offseted when switching back to 'absolute' from 'fixed'.
277
- // TODO: this also removes resizing animation which doesn't have this issue, but others.
278
- // Ideally both would animate ('move' would immediately restore 'absolute' and adjust coordinate to match,
279
- // then trigger a delay (repaint) to restore to final dest with animate) but then we need to make sure 'resizestop'
280
- // is called AFTER 'transitionend' event is received (see https://github.com/gridstack/gridstack.js/issues/2033)
281
- var transition_1 = this.dragElementOriginStyle['transition'] || null;
282
- helper_1.style.transition = this.dragElementOriginStyle['transition'] = 'none'; // can't be NULL #1973
283
- DDDraggable.originStyleProp.forEach(function (prop) { return helper_1.style[prop] = _this.dragElementOriginStyle[prop] || null; });
284
- setTimeout(function () { return helper_1.style.transition = transition_1; }, 50); // recover animation from saved vars after a pause (0 isn't enough #1973)
285
- }
286
- delete this.dragElementOriginStyle;
287
- return this;
288
- };
289
- /** @internal updates the top/left position to follow the mouse */
290
- DDDraggable.prototype._dragFollow = function (e) {
291
- var containmentRect = { left: 0, top: 0 };
292
- // if (this.helper.style.position === 'absolute') { // we use 'fixed'
293
- // const { left, top } = this.helperContainment.getBoundingClientRect();
294
- // containmentRect = { left, top };
295
- // }
296
- var style = this.helper.style;
297
- var offset = this.dragOffset;
298
- style.left = e.clientX + offset.offsetLeft - containmentRect.left + 'px';
299
- style.top = e.clientY + offset.offsetTop - containmentRect.top + 'px';
300
- };
301
- /** @internal */
302
- DDDraggable.prototype._setupHelperContainmentStyle = function () {
303
- this.helperContainment = this.helper.parentElement;
304
- if (this.helper.style.position !== 'fixed') {
305
- this.parentOriginStylePosition = this.helperContainment.style.position;
306
- if (window.getComputedStyle(this.helperContainment).position.match(/static/)) {
307
- this.helperContainment.style.position = 'relative';
308
- }
309
- }
310
- return this;
311
- };
312
- /** @internal */
313
- DDDraggable.prototype._getDragOffset = function (event, el, parent) {
314
- // in case ancestor has transform/perspective css properties that change the viewpoint
315
- var xformOffsetX = 0;
316
- var xformOffsetY = 0;
317
- if (parent) {
318
- var testEl = document.createElement('div');
319
- utils_1.Utils.addElStyles(testEl, {
320
- opacity: '0',
321
- position: 'fixed',
322
- top: 0 + 'px',
323
- left: 0 + 'px',
324
- width: '1px',
325
- height: '1px',
326
- zIndex: '-999999',
327
- });
328
- parent.appendChild(testEl);
329
- var testElPosition = testEl.getBoundingClientRect();
330
- parent.removeChild(testEl);
331
- xformOffsetX = testElPosition.left;
332
- xformOffsetY = testElPosition.top;
333
- // TODO: scale ?
334
- }
335
- var targetOffset = el.getBoundingClientRect();
336
- return {
337
- left: targetOffset.left,
338
- top: targetOffset.top,
339
- offsetLeft: -event.clientX + targetOffset.left - xformOffsetX,
340
- offsetTop: -event.clientY + targetOffset.top - xformOffsetY,
341
- width: targetOffset.width,
342
- height: targetOffset.height
343
- };
344
- };
345
- /** @internal TODO: set to public as called by DDDroppable! */
346
- DDDraggable.prototype.ui = function () {
347
- var containmentEl = this.el.parentElement;
348
- var containmentRect = containmentEl.getBoundingClientRect();
349
- var offset = this.helper.getBoundingClientRect();
350
- return {
351
- position: {
352
- top: offset.top - containmentRect.top,
353
- left: offset.left - containmentRect.left
354
- }
355
- /* not used by GridStack for now...
356
- helper: [this.helper], //The object arr representing the helper that's being dragged.
357
- offset: { top: offset.top, left: offset.left } // Current offset position of the helper as { top, left } object.
358
- */
359
- };
360
- };
361
- /** @internal properties we change during dragging, and restore back */
362
- DDDraggable.originStyleProp = ['transition', 'pointerEvents', 'position', 'left', 'top', 'minWidth', 'willChange'];
363
- return DDDraggable;
364
- }(dd_base_impl_1.DDBaseImplement));
365
- exports.DDDraggable = DDDraggable;
366
- //# sourceMappingURL=dd-draggable.js.map