Skip to content

Commit

Permalink
dropdownHorizontalPosition / dropdownVerticalPosition
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Feb 2, 2024
1 parent 1e40c55 commit d5fecf4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions haxe/ui/components/DropDown.hx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class DropDown extends Button implements IDataComponent {
@:clonable @:behaviour(DefaultBehaviour) public var dropdownWidth:Null<Float>;
@:clonable @:behaviour(DefaultBehaviour) public var dropdownHeight:Null<Float>;
@:clonable @:behaviour(DefaultBehaviour) public var dropdownSize:Null<Int>;
@:clonable @:behaviour(DefaultBehaviour) public var dropdownHorizontalPosition:String;
@:clonable @:behaviour(DefaultBehaviour) public var dropdownVerticalPosition:String;
@:clonable @:behaviour(SelectedIndexBehaviour, -1) public var selectedIndex:Int;
@:clonable @:behaviour(SelectedItemBehaviour) public var selectedItem:Dynamic;
@:clonable @:behaviour(DefaultBehaviour, false) public var searchable:Bool;
Expand Down Expand Up @@ -781,13 +783,13 @@ class DropDownEvents extends ButtonEvents {

var popupToRight = false;
var popupFromBottom = false;
if (_wrapper.screenLeft + _wrapper.actualComponentWidth > Screen.instance.actualWidth) {
if (_dropdown.dropdownHorizontalPosition == "right" || _wrapper.screenLeft + _wrapper.actualComponentWidth > Screen.instance.actualWidth) {
var left = _wrapper.screenLeft - _wrapper.actualComponentWidth + _dropdown.actualComponentWidth;
_wrapper.left = left >= 0 ? left : (Screen.instance.actualWidth / 2) - (_wrapper.actualComponentWidth / 2);
popupToRight = true;
}
_wrapper.removeClass("popup-from-bottom");
if (_wrapper.screenTop + _wrapper.actualComponentHeight > Screen.instance.actualHeight) {
if (_dropdown.dropdownVerticalPosition == "bottom" || _wrapper.screenTop + _wrapper.actualComponentHeight > Screen.instance.actualHeight) {
_wrapper.addClass("popup-from-bottom");
_wrapper.top = (_dropdown.screenTop - _wrapper.actualComponentHeight) + Toolkit.scaleY;
_wrapper.syncComponentValidation();
Expand Down

0 comments on commit d5fecf4

Please sign in to comment.