@schukai/monster 3.102.1 → 3.102.3

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.
@@ -84,7 +84,7 @@ class Panel extends CustomElement {
84
84
 
85
85
  /**
86
86
  *
87
- * @return {Monster.Components.Host.Viewer}
87
+ * @return {Panel}
88
88
  */
89
89
  [assembleMethodSymbol]() {
90
90
  super[assembleMethodSymbol]();
@@ -23,6 +23,7 @@ import { Observer } from "../../types/observer.mjs";
23
23
  import { SplitPanelStyleSheet } from "./stylesheet/split-panel.mjs";
24
24
  import { instanceSymbol } from "../../constants.mjs";
25
25
  import { internalSymbol } from "../../constants.mjs";
26
+ import { getDocument } from "../../dom/util.mjs";
26
27
 
27
28
  export { SplitPanel, TYPE_VERTICAL, TYPE_HORIZONTAL };
28
29
 
@@ -69,6 +70,8 @@ const TYPE_HORIZONTAL = "horizontal";
69
70
  *
70
71
  * @fragments /fragments/components/layout/split-panel/
71
72
  *
73
+ * @issue https://localhost.alvine.dev:8440/development/issues/closed/184.html
74
+ *
72
75
  * @example /examples/components/layout/split-panel-simple
73
76
  *
74
77
  * @since 3.54.0
@@ -294,6 +297,8 @@ function initEventHandler() {
294
297
  });
295
298
  }
296
299
 
300
+ let userSelectDefault = getDocument().body.style.userSelect;
301
+
297
302
  this[draggerElementSymbol].addEventListener("mousedown", () => {
298
303
  self[internalSymbol].getSubject().isDragging = true;
299
304
 
@@ -317,6 +322,8 @@ function initEventHandler() {
317
322
  return;
318
323
  }
319
324
 
325
+ getDocument().body.style.userSelect = "none";
326
+
320
327
  if (self.getOption("splitType") === TYPE_HORIZONTAL) {
321
328
  const containerOffsetTop = self[splitScreenElementSymbol].offsetTop;
322
329
  const topPanel = self[startPanelElementSymbol];
@@ -370,6 +377,9 @@ function initEventHandler() {
370
377
 
371
378
  const dragEventHandler = (e) => {
372
379
  self[internalSymbol].getSubject().isDragging = false;
380
+
381
+ document.body.style.userSelect = userSelectDefault;
382
+
373
383
  document.removeEventListener("mousemove", eventListener);
374
384
  document.removeEventListener("mouseup", eventListener);
375
385
  };
@@ -17,6 +17,8 @@ import { addAttributeToken } from "./attributes.mjs";
17
17
  import { ATTRIBUTE_ERRORMESSAGE } from "./constants.mjs";
18
18
  import { CustomElement, attributeObserverSymbol } from "./customelement.mjs";
19
19
  import { instanceSymbol } from "../constants.mjs";
20
+ import { DeadMansSwitch } from "../util/deadmansswitch.mjs";
21
+ import { addErrorAttribute } from "./error.mjs";
20
22
 
21
23
  export { CustomControl };
22
24
 
@@ -77,8 +79,8 @@ class CustomControl extends CustomElement {
77
79
  );
78
80
  }
79
81
 
80
- // initialize a MutationObserver to watch for attribute changes
81
- initObserver.call(this);
82
+ // watch for attribute value changes
83
+ initValueAttributeObserver.call(this);
82
84
  }
83
85
 
84
86
  /**
@@ -348,14 +350,42 @@ function getInternal() {
348
350
  return this[attachedInternalSymbol];
349
351
  }
350
352
 
353
+ const debounceValueSymbol = Symbol("debounceValue");
354
+
351
355
  /**
356
+ *
357
+ * @issue https://gitlab.schukai.com/oss/libraries/javascript/monster/-/issues/290
358
+ *
352
359
  * @private
353
360
  * @return {object}
354
361
  * @this CustomControl
355
362
  */
356
- function initObserver() {
357
- // value
363
+ function initValueAttributeObserver() {
364
+ const self = this;
365
+
358
366
  this[attributeObserverSymbol]["value"] = () => {
359
- this.setOption("value", this.getAttribute("value"));
367
+ if (self[debounceValueSymbol] instanceof DeadMansSwitch) {
368
+ try {
369
+ self[debounceValueSymbol].touch();
370
+ return;
371
+ } catch (e) {
372
+ // catch Error("has already run");
373
+ if (e.message !== "has already run") {
374
+ throw e;
375
+ }
376
+ delete self[debounceValueSymbol];
377
+ }
378
+ }
379
+
380
+ self[debounceValueSymbol] = new DeadMansSwitch(50, () => {
381
+ requestAnimationFrame(() => {
382
+ const oldValue = self.getAttribute("value");
383
+ const newValue = self.getOption("value");
384
+
385
+ if (oldValue !== newValue) {
386
+ this.setOption("value", this.getAttribute("value"));
387
+ }
388
+ });
389
+ });
360
390
  };
361
391
  }