Skip to content

Commit

Permalink
force dropdown width
Browse files Browse the repository at this point in the history
  • Loading branch information
SeonMyungLim committed May 24, 2016
1 parent 6f9179f commit 2cf562a
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 84 deletions.
2 changes: 1 addition & 1 deletion dist/entry.css
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ svg .svgBlockGroup text {
}
.entry-widget-dropdown .rect {
height: 20px;
padding: 3px 19px 3px 6px;
padding: 3px 17px 3px 6px;
width: 100%;
}
.entry-widget-dropdown .rect .left {
Expand Down
124 changes: 66 additions & 58 deletions dist/entry.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/entry.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/css/components/block.less
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ svg .svgBlockGroup text {

.rect {
height: 20px;
padding: 3px 19px 3px 6px;
padding: 3px 17px 3px 6px;
width: 100%;

.left {
Expand Down
43 changes: 24 additions & 19 deletions src/workspace/field/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,33 +183,38 @@ Entry.Utils.inherit(Entry.Field, Entry.FieldDropdown);
});
})(element, value);
}

this._position(true);
this.optionGroup.css('width', this.optionGroup.width() + 3);
this._position();
};

p._position = function() {
//inspect enough space below
var pos = this.getAbsolutePosFromDocument();
pos.y += this.box.height/2;
p._position = function(reset) {
if (!reset) {
//inspect enough space below
var pos = this.getAbsolutePosFromDocument();
pos.y += this.box.height/2;

var documentHeight = $(document).height();
var optionGroupHeight = this.optionGroup.height();
var documentHeight = $(document).height();
var optionGroupHeight = this.optionGroup.height();

//not enough space below
if (documentHeight < pos.y + optionGroupHeight) {
pos.x += this.box.width + 1;
//not enough space below
if (documentHeight < pos.y + optionGroupHeight) {
pos.x += this.box.width + 1;

var relPos = this.getAbsolutePosFromBoard();
var domHeight = this._blockView.getBoard().svgDom.height();
domHeight -= domHeight - relPos.y;
var relPos = this.getAbsolutePosFromBoard();
var domHeight = this._blockView.getBoard().svgDom.height();
domHeight -= domHeight - relPos.y;

if (domHeight - 20 < optionGroupHeight) {
domHeight -= domHeight % 20;
this.optionGroup.height(domHeight)
}
if (domHeight - 20 < optionGroupHeight) {
domHeight -= domHeight % 20;
this.optionGroup.height(domHeight)
}

pos.y -= this.optionGroup.height();
} else pos.x += this.box.width/2 - this.optionGroup.width()/2;
pos.y -= this.optionGroup.height();
} else pos.x += this.box.width/2 - this.optionGroup.width()/2;
} else {
pos = { x: 0, y: 0 };
}

this.optionGroup.css({left: pos.x, top: pos.y});
};
Expand Down
3 changes: 2 additions & 1 deletion src/workspace/field/dropdownDynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ Entry.Utils.inherit(Entry.FieldDropdown, Entry.FieldDropdownDynamic);
});
})(element, value);
}

this._position(true);
this.optionGroup.css('width', this.optionGroup.width() +3);
this._position();
};

Expand Down

0 comments on commit 2cf562a

Please sign in to comment.