Skip to content

Commit

Permalink
Skip component resizer if already enabled #5753
Browse files Browse the repository at this point in the history
  • Loading branch information
artf committed Mar 16, 2024
1 parent 33dbd5a commit e70769f
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/commands/view/SelectComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ let showOffsets: boolean;
*
*/
export default {
activeResizer: false,

init() {
this.onSelect = debounce(this.onSelect, 0);
bindAll(
Expand Down Expand Up @@ -396,12 +398,17 @@ export default {
...resizableOpts
} = isObject(resizable) ? resizable : {};

if (hasCustomResize || !el) return;
if (hasCustomResize || !el || this.activeResizer) return;

let modelToStyle: any;
const { config } = em;
const pfx = config.stylePrefix || '';
const resizeClass = `${pfx}resizing`;
const self = this;
const resizeEventOpts = {
component: model,
el,
};

const toggleBodyClass = (method: string, e: any, opts: any) => {
const docs = opts.docs;
Expand Down Expand Up @@ -445,20 +452,23 @@ export default {
config.unitHeight = getUnitFromValue(currentHeight);
config.unitWidth = getUnitFromValue(currentWidth);
}
self.activeResizer = true;
editor.trigger('component:resize', { ...resizeEventOpts, type: 'start' });
},

// Update all positioned elements (eg. component toolbar)
onMove(ev) {
onMove(ev);
editor.trigger('component:resize');
editor.trigger('component:resize', { ...resizeEventOpts, type: 'move' });
},

onEnd(ev, opts) {
onEnd(ev, opts);
toggleBodyClass('remove', ev, opts);
editor.trigger('component:resize');
editor.trigger('component:resize', { ...resizeEventOpts, type: 'end' });
canvas.toggleFramesEvents(true);
showOffsets = true;
self.activeResizer = false;
},

updateTarget(el, rect, options) {
Expand Down

0 comments on commit e70769f

Please sign in to comment.