Skip to content

Commit

Permalink
force dropdown position once
Browse files Browse the repository at this point in the history
  • Loading branch information
SeonMyungLim committed May 25, 2016
1 parent 2cf562a commit b697daa
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 50 deletions.
2 changes: 2 additions & 0 deletions dist/entry.css
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,8 @@ svg .svgBlockGroup text {
color: #000;
z-index: 1001;
overflow: auto;
left: 0;
top: 0;
}
.entry-widget-dropdown .rect {
height: 20px;
Expand Down
30 changes: 11 additions & 19 deletions dist/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -16841,27 +16841,21 @@ Entry.Utils.inherit(Entry.Field, Entry.FieldDropdown);
});
})(h, f);
}
this._position(!0);
this.optionGroup.css("width", this.optionGroup.width() + 3);
this._position();
};
b._position = function(a) {
if (a) {
a = {x:0, y:0};
b._position = function() {
var a = this.getAbsolutePosFromDocument();
a.y += this.box.height / 2;
var b = $(document).height(), d = this.optionGroup.height();
if (b < a.y + d) {
a.x += this.box.width + 1;
var b = this.getAbsolutePosFromBoard(), e = this._blockView.getBoard().svgDom.height(), e = e - (e - b.y);
e - 20 < d && this.optionGroup.height(e - e % 20);
a.y -= this.optionGroup.height();
} else {
a = this.getAbsolutePosFromDocument();
a.y += this.box.height / 2;
var b = $(document).height(), d = this.optionGroup.height();
if (b < a.y + d) {
a.x += this.box.width + 1;
var b = this.getAbsolutePosFromBoard(), e = this._blockView.getBoard().svgDom.height(), e = e - (e - b.y);
e - 20 < d && this.optionGroup.height(e - e % 20);
a.y -= this.optionGroup.height();
} else {
a.x += this.box.width / 2 - this.optionGroup.width() / 2;
}
a.x += this.box.width / 2 - this.optionGroup.width() / 2;
}
this.optionGroup.css({left:a.x, top:a.y});
this.optionGroup.css({left:a.x, top:a.y, width:this.optionGroup.width() + 3});
};
b.applyValue = function(a) {
this.value != a && this.setValue(a);
Expand Down Expand Up @@ -16933,8 +16927,6 @@ Entry.Utils.inherit(Entry.FieldDropdown, Entry.FieldDropdownDynamic);
});
})(g, e);
}
this._position(!0);
this.optionGroup.css("width", this.optionGroup.width() + 3);
this._position();
};
})(Entry.FieldDropdownDynamic.prototype);
Expand Down
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: 2 additions & 0 deletions src/css/components/block.less
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ svg .svgBlockGroup text {
color: #000;
z-index: 1001;
overflow: auto;
left: 0;
top: 0;

.rect {
height: 20px;
Expand Down
47 changes: 22 additions & 25 deletions src/workspace/field/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,40 +183,37 @@ 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(reset) {
if (!reset) {
//inspect enough space below
var pos = this.getAbsolutePosFromDocument();
pos.y += this.box.height/2;
p._position = function() {
//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;
} else {
pos = { x: 0, y: 0 };
}
pos.y -= this.optionGroup.height();
} else pos.x += this.box.width/2 - this.optionGroup.width()/2;

this.optionGroup.css({left: pos.x, top: pos.y});
this.optionGroup.css({
left: pos.x, top: pos.y,
width: this.optionGroup.width() + 3
});
};

p.applyValue = function(value) {
Expand Down
2 changes: 0 additions & 2 deletions src/workspace/field/dropdownDynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ 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 b697daa

Please sign in to comment.