interact.js icon indicating copy to clipboard operation
interact.js copied to clipboard

Element moves when i resize it after toggling the resizable options

Open dlmu-lq opened this issue 7 years ago • 2 comments

[Codepen] [https://codepen.io/dlmu-lq/pen/xedRme]

// pseudo code dragInteractor = interact(".resize-drag").resizable({...}) dragInteractor.resizable(false); dragInteractor = interact(".resize-drag").resizable({...})

Expected behavior

First, make a div resizable,it works fine, after 2 seconds, disable it; When I want to resize it again after re-enable it, the div should be resizable as new.

Actual behavior

But when I resize it again after re-enable it, the div will move when I resize it from left or top. Reisizing it from bottom or right works just fine.

System configuration

interact.js version: interactjs@next Browser name and version: Chrome 73.0.3683.86 Operating System: Windows 10 (1809) (17763.437)

dlmu-lq avatar Apr 11 '19 08:04 dlmu-lq

You're adding the resizemove listener multiple times with .on().

You could instead use the listeners array to clear previous listeners and add new ones in the action options object.

interactable.resizable({
  listeners: [{ move: function (event) {...} }]
  // ...
})

taye avatar Apr 15 '19 19:04 taye

@taye Thanks!

dlmu-lq avatar Apr 17 '19 07:04 dlmu-lq