Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canvas initiation with constraints #29

Closed
procop95 opened this issue Apr 26, 2019 · 3 comments
Closed

Canvas initiation with constraints #29

procop95 opened this issue Apr 26, 2019 · 3 comments

Comments

@procop95
Copy link

procop95 commented Apr 26, 2019

Dears.

this issue is related to issue #7 opened by me previously.
problem is: in cases when canvas is instantiated by calling
canvas = new draw2d.Canvas("canvas", 4000, 4000) - without directly mentioning css {width: 4000px; height: 4000px} in container;
will cause figures not be able to be moved outside initial area (viewport) of the container.

this behaviour is caused by line 121 of Canvas.js:

// installed to all added figures to avoid that a figure can be placed outside the canvas area
// during a drag&drop operation
this.regionDragDropConstraint = new draw2d.policy.figure.RegionEditPolicy(0, 0, this.getWidth(), this.getHeight())

where this.getWidth() and this.getHeight() will return initial viewport dimensions.

change this to:

   this.regionDragDropConstraint = new draw2d.policy.figure.RegionEditPolicy(0, 0, this.initialWidth, this.initialWidth)

will do proper job, if you agree.

thanks
Alex

@InannaInai
Copy link

You have an error in your solution:
I think it should be:
this.regionDragDropConstraint = new draw2d.policy.figure.RegionEditPolicy(0, 0, this.initialWidth, this.initialHeight)

@fmaiabatista
Copy link

This fix (last arg corrected to this.initialHeight) solved my issue. This line was also causing scrolling to malfunction.

@freegroup
Copy link
Owner

fixed with version 1.0.23. the width/height in the constructor is propagated as CSS attribute to the named DIV

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants