taye / interact.js

JavaScript drag and drop, resizing and multi-touch gestures with inertia and snapping for modern browsers (and also IE9+)

Home Page:http://interactjs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`modifier.disable()` Does not work as intended

yulafezmesi opened this issue · comments

Hi,

First of all, thank you for the great framework!

Expected behavior

My goal is to disable the modifier in case only the user selects the corners of the box otherwise modifier shouldn't work.

const preserveRatio = interact.modifiers.aspectRatio({
  ratio: 'preserve',
  enabled: false,
})

if (
    (left && bottom) ||
    (right && top) ||
    (left && top) ||
    (right && bottom)
  ) {
    preserveRatio.enable()
  } else {
    preserveRatio.disable()
  } 

I believe, when you disable modifiers it should work as if there are no modifiers. Or should I do something else apart from disabling it?

You can reproduce it here:
https://codepen.io/lakers19/pen/GRdVZEw?editors=1010

Actual behavior

If you select the corners, the modifier will be activated, however, when the user selects only the right bullet in the box, it will resize everything. it should resize only the right side of the box.

System configuration

interact.js version: 1.10.17
Browser name and version: Chrome 106.0.5249.119
Operating System: MacOS M1

commented

Working on it!