From 2f257481e6cfcba95df0ac1244b3a93a13f2974f Mon Sep 17 00:00:00 2001 From: Benjamin Babik Date: Tue, 28 Feb 2017 11:03:11 +0000 Subject: [PATCH 1/3] lazy loading through dom-if --- paper-tree-node.html | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/paper-tree-node.html b/paper-tree-node.html index 1c20434..093b126 100755 --- a/paper-tree-node.html +++ b/paper-tree-node.html @@ -124,13 +124,15 @@ - + From 27c5a56ee09144a7814182f2a2d8f503d3605c8c Mon Sep 17 00:00:00 2001 From: Florian Maffini Date: Wed, 1 Mar 2017 17:52:17 +0100 Subject: [PATCH 2/3] dispatching toggle as async event --- demo/index.html | 10 ++++++---- demo/lazyloading.html | 10 ++++++---- paper-tree-node.html | 3 +-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/demo/index.html b/demo/index.html index 7209ad5..e578efd 100755 --- a/demo/index.html +++ b/demo/index.html @@ -206,11 +206,13 @@

Lazy loading demo

template.onToggle = function(event) { var target = event.detail; - !target.loaded && target.getChildren().forEach(function(child){ + if (!target.loaded) { target.loaded = true; - // Fetching children ... - this.fetchChildren(child); - }, this); + target.getChildren().forEach(function(child){ + // Fetching children ... + this.fetchChildren(child); + }, this); + } }, template.setLoadingState = function(node, enabled) { diff --git a/demo/lazyloading.html b/demo/lazyloading.html index 32fdbef..84387b0 100644 --- a/demo/lazyloading.html +++ b/demo/lazyloading.html @@ -43,11 +43,13 @@

Lazy loading paper-tree demo

template.onToggle = function(event) { var target = event.detail; - !target.loaded && target.getChildren().forEach(function(child){ + if (!target.loaded) { target.loaded = true; - // Fetching children ... - this.fetchChildren(child); - }, this); + target.getChildren().forEach(function(child){ + // Fetching children ... + this.fetchChildren(child); + }, this); + } }, template.setLoadingState = function(node, enabled) { diff --git a/paper-tree-node.html b/paper-tree-node.html index 093b126..a107285 100755 --- a/paper-tree-node.html +++ b/paper-tree-node.html @@ -187,7 +187,6 @@ /** * The `toggle` event is fired whenever a tree node is expanded or collapsed. - * This event can be used by the host to lazy load grandchildren. * * @event toggle */ @@ -244,7 +243,7 @@ */ toggleChildren: function() { this.set("data.open", !this.data.open && this.data.children && this.data.children.length); - this.fire("toggle", this); + setTimeout(this.fire.bind(this, "toggle", this)); } }); From 8758294f9a5a01cae2e3a76f07eee83db357aca7 Mon Sep 17 00:00:00 2001 From: Benjamin Babik Date: Sat, 4 Mar 2017 12:57:36 +0000 Subject: [PATCH 3/3] swapped attr binding for property binding --- paper-tree-node.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paper-tree-node.html b/paper-tree-node.html index a107285..4867eb3 100755 --- a/paper-tree-node.html +++ b/paper-tree-node.html @@ -124,7 +124,7 @@ -