From 1e02fcb10247f568867dc126d4e426c5c21bc56d Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Wed, 10 Jan 2018 23:42:08 +0100 Subject: [PATCH] Prevent issues with devices with the same width. Fixes #727 --- src/canvas/view/FrameView.js | 13 ++++++++++--- src/editor/index.js | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/canvas/view/FrameView.js b/src/canvas/view/FrameView.js index 7a35a46cb..fd1971175 100644 --- a/src/canvas/view/FrameView.js +++ b/src/canvas/view/FrameView.js @@ -27,11 +27,18 @@ module.exports = require('backbone').View.extend({ const em = this.em; const device = em.getDeviceModel(); const style = this.el.style; - style.width = device ? device.get('width') : ''; - style.height = device ? device.get('height') : ''; + const currW = style.width || ''; + const currH = style.height || ''; + const newW = device ? device.get('width') : ''; + const newH = device ? device.get('height') : ''; + const noChanges = currW == newW && currH == newH; + style.width = newW; + style.height = newH; this.udpateOffset(); + // Prevent fixed highlighting box which appears when on + // component hover during the animation em.stopDefault({ preserveSelected: 1 }); - this.$el.on(motionsEv, this.udpateOffset); + noChanges ? this.udpateOffset() : this.$el.on(motionsEv, this.udpateOffset); }, udpateOffset() { diff --git a/src/editor/index.js b/src/editor/index.js index fad4c33e7..f8419d863 100644 --- a/src/editor/index.js +++ b/src/editor/index.js @@ -10,6 +10,7 @@ * * ## Components * * `component:add` - Triggered when a new component is added to the editor, the model is passed as an argument to the callback + * * `component:clone` - Triggered when a new component is added by a clone command, the model is passed as an argument to the callback * * `component:update` - Triggered when a component is updated (moved, styled, etc.), the model is passed as an argument to the callback * * `component:update:{propertyName}` - Listen any property change, the model is passed as an argument to the callback * * `component:styleUpdate` - Triggered when the style of the component is updated, the model is passed as an argument to the callback