[QUESTION] Component resize event
Question
I have a canvas component and I need to be able to register resize events for it.
After diving trough the code and looking for relevant model events all I could come up with, that would actually trigger on the resize is this:
handleUpdate (e) {
if (this.prevWidth !== this.el.clientWidth ||
this.prevHeight !== this.el.clientHeight) {
this.prevWidth = this.el.clientWidth
this.prevHeight = this.el.clientHeight
this.handleResize()
}
},
render () {
defaultType.view.prototype.render.apply(this, arguments)
this.prevHeight = null
this.prevWidth = null
this.handleUpdate = this.handleUpdate.bind(this)
editor.on('component:styleUpdate', this.handleUpdate)
return this
}
Which works, but is kinda hacky.
Is there a better suited event?
Answers (2)
Hi David, I think currently is the best you can do, but I'm open for suggestions to make it less hacky
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1414
[QUESTION] Component "first render" event
Hi. I'm developing a plugin for charts using chart.js. I need to persist the model of the chart inside the generated component to render th...
Issue #754
ES6 class in component script
I would like to use ES6 classes in the components script attribute. When I drop the component onto the canvas the error message "_classCall...
Issue #828
[QUESTION] Components 'add' event fires different number of times
Hi, I've noticed that if I add the following code in my custom component the event fires differently depending on whether a new child compo...
Issue #1959
[Question] Edit innerHTML in a custom button
Hi All, I am trying to change the text in a button component, but I am not able to edit it. I added this type: I included the editable: tru...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.