From 25a9a9fa593f6090383c803328832a29b23bbd3e Mon Sep 17 00:00:00 2001 From: Adam Procter <adamprocter@researchnot.es> Date: Wed, 23 Dec 2020 14:49:51 +0000 Subject: [PATCH] resize observer ... not working --- app/src/components/NodesLayer.vue | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/app/src/components/NodesLayer.vue b/app/src/components/NodesLayer.vue index 1d18d50..4d7cae0 100644 --- a/app/src/components/NodesLayer.vue +++ b/app/src/components/NodesLayer.vue @@ -296,6 +296,10 @@ export default { } }, + beforeDestroy() { + if (this.observer) this.observer.unobserve(this.$refs.box) + }, + methods: { chooseColor(color, nodeid) { this.$store.dispatch('colorNode', { nodeid, color }) @@ -337,11 +341,27 @@ export default { } } }, - onResize(x, y, width, height) { - this.localx = x - this.localy = y + + onResize() { + const node = this.$refs.node, + width = this.$refs.node.offsetWidth + 'px', + height = this.$refs.node.offsetHeight + 'px' + console.log(node) this.width = width this.height = height + + this.$emit('resize', { width, height }) + + // this.localx = x + // this.localy = y + // this.width = width + // this.height = height + }, + + initObserver() { + const observer = new ResizeObserver(this.onResize) + observer.observe(this.$refs.node) + this.observer = observer }, onResizestop(x, y, width, height) { // var nodecontentHeight = document.getElementById(this.nodeid).clientHeight -- GitLab