Issue #1355Opened August 10, 2018by david-polak0 reactions

[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)

artfAugust 13, 20180 reactions

Hi David, I think currently is the best you can do, but I'm open for suggestions to make it less hacky

lock[bot]September 17, 20190 reactions

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.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.