You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2020/04/28 15:59:40 UTC

[myfaces-tobago] branch master updated: fix this.data in Split Layout

This is an automated email from the ASF dual-hosted git repository.

lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git


The following commit(s) were added to refs/heads/master by this push:
     new 1d336c9  fix this.data in Split Layout
1d336c9 is described below

commit 1d336c9c4cc05f13ffd81211284856011f76e925
Author: Jasmin Kroeger <ja...@irian.eu>
AuthorDate: Tue Apr 28 10:54:45 2020 +0200

    fix this.data in Split Layout
    
    * this.data is only initialized when the splitter is changed and not when only the mouse is moved
---
 .../src/main/npm/ts/tobago-split-layout.ts           | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-split-layout.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-split-layout.ts
index 5343ddc..1478c1f 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-split-layout.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-split-layout.ts
@@ -82,10 +82,12 @@ class SplitLayout extends HTMLElement {
     event.preventDefault();
     const data = SplitLayoutMousedown.load();
     const previousArea = data.previous;
-    if (this.orientation === "horizontal") {
-      previousArea.style.width = String(event.pageX - this.offset) + "px";
-    } else {
-      previousArea.style.height = String(event.pageY - this.offset) + "px";
+    if (previousArea) {
+      if (this.orientation === "horizontal") {
+        previousArea.style.width = String(event.pageX - this.offset) + "px";
+      } else {
+        previousArea.style.height = String(event.pageY - this.offset) + "px";
+      }
     }
   }
 
@@ -141,17 +143,19 @@ class SplitLayoutMousedown {
   }
 
   private constructor(data: SplitLayoutMousedownData | string) {
-    this.data = typeof data === "string" ? JSON.parse(data) : data;
+    if (data) {
+      this.data = typeof data === "string" ? JSON.parse(data) : data;
+    }
   }
 
   get splitter(): HTMLElement {
-    return document.getElementById(this.data.splitLayoutId).getElementsByClassName(
+    return this.data ? document.getElementById(this.data.splitLayoutId).getElementsByClassName(
         this.data.horizontal ? "tobago-splitLayout-horizontal" : "tobago-splitLayout-vertical")
-        .item(this.data.splitterIndex) as HTMLElement;
+        .item(this.data.splitterIndex) as HTMLElement : null;
   }
 
   get previous(): HTMLElement {
-    return DomUtils.previousElementSibling(this.splitter);
+    return this.splitter ? DomUtils.previousElementSibling(this.splitter) : null;
   }
 }