1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-02 07:47:32 +00:00

[dropdown widget] improved menu position

This commit is contained in:
llj 2016-06-15 17:20:21 +08:00
parent 5487461541
commit 341d029b9f

View File

@ -58,10 +58,11 @@ define([
hide: function() {
app.ui.currentDropdown = null;
this.$('.sf-dropdown-menu').addClass('hide');
this.$('.sf-dropdown-menu').addClass('hide').removeAttr('style'); // `removeAttr('style')`: clear position info
},
show: function() {
var $toggle = this.$('.sf-dropdown-toggle');
var $menu = this.$('.sf-dropdown-menu');
app.ui.currentDropdown = this;
if (this.options.right) {
@ -69,6 +70,9 @@ define([
} else {
$menu.css('left', this.options.left);
}
if ($toggle.offset().top + $toggle.outerHeight(true) + $menu.outerHeight(true) > $(window).scrollTop() + $(window).height()) {
$menu.css({'bottom': $toggle.outerHeight(true) + 4});
}
this.$('.sf-dropdown-menu').removeClass('hide');
},