aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorTerry Truong <terry06890@gmail.com>2022-03-10 20:43:40 +1100
committerTerry Truong <terry06890@gmail.com>2022-03-10 21:04:51 +1100
commit0b309b2a98ed0ca14e5fdd81aead1ca8a5884c13 (patch)
tree13b0a79ab5f659270d8c8706d27ae40120d566a4 /src/components
parentf4a6b6a669f2431ae5ea682ebdbde3f9bf3a7114 (diff)
Add throttling for resizing. Add array-creation helper functions.
Diffstat (limited to 'src/components')
-rw-r--r--src/components/TileTree.vue12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/components/TileTree.vue b/src/components/TileTree.vue
index 65201c5..68e180d 100644
--- a/src/components/TileTree.vue
+++ b/src/components/TileTree.vue
@@ -20,6 +20,7 @@ export default {
tree: this.initTree(tol, 1),
width: document.documentElement.clientWidth,
height: document.documentElement.clientHeight,
+ resizeThrottled: false,
}
},
methods: {
@@ -43,9 +44,14 @@ export default {
return tree;
},
onResize(){
- this.width = document.documentElement.clientWidth;
- this.height = document.documentElement.clientHeight;
- this.tryLayout(); //use best-effort collapsing-layout?
+ if (!this.resizeThrottled){
+ this.width = document.documentElement.clientWidth;
+ this.height = document.documentElement.clientHeight;
+ this.tryLayout(); //use best-effort collapsing-layout?
+ //prevent re-triggering until after a delay
+ this.resizeThrottled = true;
+ setTimeout(() => {this.resizeThrottled = false;}, 100);
+ }
},
onInnerTileClicked(nodeList){
//nodeList holds an array of tree-objects, from the clicked-on-tile's tree-object upward