Dropdown.js: return early (#2783)

pull/2788/head
XhmikosR 2020-06-03 19:05:36 +03:00 committed by GitHub
parent 312e083fc0
commit f091c5d510
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 18 deletions

View File

@ -58,26 +58,28 @@ class Dropdown {
fixPosition() {
const $element = $(Selector.DROPDOWN_MENU_ACTIVE)
if ($element.length !== 0) {
if ($element.hasClass(ClassName.DROPDOWN_RIGHT)) {
$element.css('left', 'inherit')
$element.css('right', 0)
} else {
$element.css('left', 0)
$element.css('right', 'inherit')
}
if ($element.length === 0) {
return
}
const offset = $element.offset()
const width = $element.width()
const visiblePart = $(window).width() - offset.left
if ($element.hasClass(ClassName.DROPDOWN_RIGHT)) {
$element.css('left', 'inherit')
$element.css('right', 0)
} else {
$element.css('left', 0)
$element.css('right', 'inherit')
}
if (offset.left < 0) {
$element.css('left', 'inherit')
$element.css('right', (offset.left - 5))
} else if (visiblePart < width) {
$element.css('left', 'inherit')
$element.css('right', 0)
}
const offset = $element.offset()
const width = $element.width()
const visiblePart = $(window).width() - offset.left
if (offset.left < 0) {
$element.css('left', 'inherit')
$element.css('right', (offset.left - 5))
} else if (visiblePart < width) {
$element.css('left', 'inherit')
$element.css('right', 0)
}
}