@schukai/monster 4.10.3 → 4.10.4

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
 
4
4
 
5
+ ## [4.10.4] - 2025-05-20
6
+
7
+ ### Bug Fixes
8
+
9
+ - Add touch support for drag events in split-panel component
10
+
11
+
12
+
5
13
  ## [4.10.3] - 2025-05-20
6
14
 
7
15
  ### Bug Fixes
package/package.json CHANGED
@@ -1 +1 @@
1
- {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.7.0","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.10.3"}
1
+ {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.7.0","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.10.4"}
@@ -269,8 +269,7 @@ function initEventHandler() {
269
269
 
270
270
  this[internalSymbol].getSubject().isDragging = false;
271
271
 
272
- // @todo: add better touch support
273
- const eventTypes = ["dblclick", "touchstart"];
272
+ const eventTypes = ["dblclick"];
274
273
  for (const eventType of eventTypes) {
275
274
  this[draggerElementSymbol].addEventListener(eventType, () => {
276
275
  self[internalSymbol].getSubject().isDragging = false;
@@ -297,6 +296,64 @@ function initEventHandler() {
297
296
  });
298
297
  }
299
298
 
299
+ this[draggerElementSymbol].addEventListener("touchstart", (startEvent) => {
300
+
301
+ startEvent.preventDefault();
302
+ self[internalSymbol].getSubject().isDragging = true;
303
+
304
+ const dragTouchMove = (e) => {
305
+ if (!self[internalSymbol].getSubject().isDragging) return;
306
+
307
+ const touch = e.touches[0];
308
+ if (!touch) return;
309
+
310
+ // identical logic as in mousemove - but with touch.clientX/clientY
311
+ let draggerWidth = getComputedStyle(self[draggerElementSymbol]).getPropertyValue("--monster-dragger-width") || "0";
312
+
313
+ if (self.getOption("splitType") === TYPE_HORIZONTAL) {
314
+ const containerOffsetTop = self[splitScreenElementSymbol].offsetTop;
315
+ let newTopHeight = touch.clientY - containerOffsetTop;
316
+
317
+ const min = this.getOption("dimension").min;
318
+ const max = this.getOption("dimension").max;
319
+ const topAsPercent = (newTopHeight / this[splitScreenElementSymbol].offsetHeight) * 100;
320
+
321
+ if (parseInt(min) > topAsPercent) newTopHeight = min;
322
+ else if (parseInt(max) < topAsPercent) newTopHeight = max;
323
+ else newTopHeight = topAsPercent + "%";
324
+
325
+ const newTopHeightPx = (parseInt(newTopHeight) / 100) * this[splitScreenElementSymbol].offsetHeight;
326
+
327
+ self[startPanelElementSymbol].style.height = `${newTopHeightPx}px`;
328
+ self[endPanelElementSymbol].style.height = `calc(100% - ${newTopHeightPx}px - ${draggerWidth})`;
329
+ } else {
330
+ const containerOffsetLeft = self[splitScreenElementSymbol].offsetLeft;
331
+ let newLeftWidth = touch.clientX - containerOffsetLeft;
332
+
333
+ const min = this.getOption("dimension").min;
334
+ const max = this.getOption("dimension").max;
335
+ const leftAsPercent = (newLeftWidth / this[splitScreenElementSymbol].offsetWidth) * 100;
336
+
337
+ if (parseInt(min) > leftAsPercent) newLeftWidth = min;
338
+ else if (parseInt(max) < leftAsPercent) newLeftWidth = max;
339
+ else newLeftWidth = leftAsPercent + "%";
340
+
341
+ self[startPanelElementSymbol].style.width = `${newLeftWidth}`;
342
+ self[endPanelElementSymbol].style.width = `calc(100% - ${newLeftWidth} - ${draggerWidth})`;
343
+ }
344
+ };
345
+
346
+ const dragTouchEnd = () => {
347
+ self[internalSymbol].getSubject().isDragging = false;
348
+ document.removeEventListener("touchmove", dragTouchMove);
349
+ document.removeEventListener("touchend", dragTouchEnd);
350
+ };
351
+
352
+ document.addEventListener("touchmove", dragTouchMove, { passive: false });
353
+ document.addEventListener("touchend", dragTouchEnd);
354
+ });
355
+
356
+
300
357
  let userSelectDefault = getDocument().body.style.userSelect;
301
358
 
302
359
  this[draggerElementSymbol].addEventListener("mousedown", () => {