svgdotjs / svg.resize.js

An extension of svg.js which allows to resize elements which are selected
MIT License
92 stars 67 forks source link

How to limit the boundary when changing the size #68

Open iuenieZachary opened 2 months ago

iuenieZachary commented 2 months ago

I have looked at the demo and readme documentation and found no parameters that can configure the boundary limit, but after looking at the source code, it seems that I have seen the relevant boundary limit, but do not know how to configure it

Fuzzyma commented 2 months ago

Where did you see the relevant code? Can you link it? Because I cant find it

iuenieZachary commented 2 months ago

I saw that the box in the movePoint function in the Resizehandler.js file uses the maxBoxFromPoints method, maybe I misunderstood. My main question is what parameter or method is being used to replace the constraint parameter after it is removed

iuenieZachary commented 2 months ago

In version 2.0.1, how do I need to achieve the same effect as constraint parameters

Fuzzyma commented 2 months ago

None, it was removed. You can realize the same behavior by listening to the resize event and call event.preventDefault() if the new dimensions are not to your liking:

rect.on('resize', (event) => {
  console.log(event.detail.box)

  if (event.detail.box.width > 300) event.preventDefault()
})
iuenieZachary commented 2 months ago

Ok, thank you very much