mirror of https://github.com/ColorlibHQ/AdminLTE
Dropdown.js: return early (#2783)
parent
312e083fc0
commit
f091c5d510
|
@ -58,26 +58,28 @@ class Dropdown {
|
||||||
fixPosition() {
|
fixPosition() {
|
||||||
const $element = $(Selector.DROPDOWN_MENU_ACTIVE)
|
const $element = $(Selector.DROPDOWN_MENU_ACTIVE)
|
||||||
|
|
||||||
if ($element.length !== 0) {
|
if ($element.length === 0) {
|
||||||
if ($element.hasClass(ClassName.DROPDOWN_RIGHT)) {
|
return
|
||||||
$element.css('left', 'inherit')
|
}
|
||||||
$element.css('right', 0)
|
|
||||||
} else {
|
|
||||||
$element.css('left', 0)
|
|
||||||
$element.css('right', 'inherit')
|
|
||||||
}
|
|
||||||
|
|
||||||
const offset = $element.offset()
|
if ($element.hasClass(ClassName.DROPDOWN_RIGHT)) {
|
||||||
const width = $element.width()
|
$element.css('left', 'inherit')
|
||||||
const visiblePart = $(window).width() - offset.left
|
$element.css('right', 0)
|
||||||
|
} else {
|
||||||
|
$element.css('left', 0)
|
||||||
|
$element.css('right', 'inherit')
|
||||||
|
}
|
||||||
|
|
||||||
if (offset.left < 0) {
|
const offset = $element.offset()
|
||||||
$element.css('left', 'inherit')
|
const width = $element.width()
|
||||||
$element.css('right', (offset.left - 5))
|
const visiblePart = $(window).width() - offset.left
|
||||||
} else if (visiblePart < width) {
|
|
||||||
$element.css('left', 'inherit')
|
if (offset.left < 0) {
|
||||||
$element.css('right', 0)
|
$element.css('left', 'inherit')
|
||||||
}
|
$element.css('right', (offset.left - 5))
|
||||||
|
} else if (visiblePart < width) {
|
||||||
|
$element.css('left', 'inherit')
|
||||||
|
$element.css('right', 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue