Skip to content

Commit

Permalink
add constraints for min size of nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
lakhoune committed May 29, 2023
1 parent 3706509 commit 4d1d79e
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/es6/canvas_widget/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,9 @@ export class AbstractEdge extends AbstractEntity {
* @param {number} zIndex Position of node on z-axis
*/
export class AbstractNode extends AbstractEntity {
MIN_WIDTH = 50;
MIN_HEIGHT = 50;

nodeSelector;
_$node;
_isBeingDragged = false;
Expand All @@ -1559,6 +1562,11 @@ export class AbstractNode extends AbstractEntity {
y
) {
super(id);
if (height < this.MIN_HEIGHT) height = this.MIN_HEIGHT;
if (width < this.MIN_WIDTH) width = this.MIN_WIDTH;
if (top < 0) top = 0;
if (left < 0) left = 0;

var that = this;
y = y || window.y;
if (!y) {
Expand Down Expand Up @@ -2482,8 +2490,14 @@ export class AbstractNode extends AbstractEntity {
* @param {number} offsetY Offset in y-direction
*/
this.resize = function (offsetX, offsetY) {
_appearance.width += offsetX;
_appearance.height += offsetY;
_appearance.width =
_appearance.width + offsetX > this.MIN_WIDTH
? _appearance.width + offsetX
: this.MIN_WIDTH;
_appearance.height =
_appearance.height + offsetY > this.MIN_HEIGHT
? _appearance.height + offsetY
: this.MIN_HEIGHT;
if (_ymap) {
y.transact(() => {
_ymap.set("width", _appearance.width);
Expand Down

0 comments on commit 4d1d79e

Please sign in to comment.