fixed control-siderbar with fixed footer/navbar

pull/3187/head
REJack 4 years ago
parent d905bd027f
commit 0421dca188

@ -152,10 +152,34 @@ class ControlSidebar {
}) })
} }
_isNavbarFixed() {
const $body = $('body')
return (
$body.hasClass(CLASS_NAME_NAVBAR_FIXED) ||
$body.hasClass(CLASS_NAME_NAVBAR_SM_FIXED) ||
$body.hasClass(CLASS_NAME_NAVBAR_MD_FIXED) ||
$body.hasClass(CLASS_NAME_NAVBAR_LG_FIXED) ||
$body.hasClass(CLASS_NAME_NAVBAR_XL_FIXED)
)
}
_isFooterFixed() {
const $body = $('body')
return (
$body.hasClass(CLASS_NAME_FOOTER_FIXED) ||
$body.hasClass(CLASS_NAME_FOOTER_SM_FIXED) ||
$body.hasClass(CLASS_NAME_FOOTER_MD_FIXED) ||
$body.hasClass(CLASS_NAME_FOOTER_LG_FIXED) ||
$body.hasClass(CLASS_NAME_FOOTER_XL_FIXED)
)
}
_fixScrollHeight() { _fixScrollHeight() {
const $body = $('body') const $body = $('body')
const $controlSidebar = $(this._config.target)
if (!$body.hasClass(CLASS_NAME_LAYOUT_FIXED)) { if (!$body.hasClass(CLASS_NAME_LAYOUT_FIXED)) {
$controlSidebar.attr('style', 'display: block;')
return return
} }
@ -170,23 +194,10 @@ class ControlSidebar {
top: $(window).scrollTop() top: $(window).scrollTop()
} }
const navbarFixed = ( const navbarFixed = this._isNavbarFixed() && $(SELECTOR_HEADER).css('position') === 'fixed'
$body.hasClass(CLASS_NAME_NAVBAR_FIXED) ||
$body.hasClass(CLASS_NAME_NAVBAR_SM_FIXED) ||
$body.hasClass(CLASS_NAME_NAVBAR_MD_FIXED) ||
$body.hasClass(CLASS_NAME_NAVBAR_LG_FIXED) ||
$body.hasClass(CLASS_NAME_NAVBAR_XL_FIXED)
) && $(SELECTOR_HEADER).css('position') === 'fixed'
const footerFixed = ( const footerFixed = this._isFooterFixed() && $(SELECTOR_FOOTER).css('position') === 'fixed'
$body.hasClass(CLASS_NAME_FOOTER_FIXED) ||
$body.hasClass(CLASS_NAME_FOOTER_SM_FIXED) ||
$body.hasClass(CLASS_NAME_FOOTER_MD_FIXED) ||
$body.hasClass(CLASS_NAME_FOOTER_LG_FIXED) ||
$body.hasClass(CLASS_NAME_FOOTER_XL_FIXED)
) && $(SELECTOR_FOOTER).css('position') === 'fixed'
const $controlSidebar = $(this._config.target)
const $controlsidebarContent = $(`${this._config.target}, ${this._config.target} ${SELECTOR_CONTROL_SIDEBAR_CONTENT}`) const $controlsidebarContent = $(`${this._config.target}, ${this._config.target} ${SELECTOR_CONTROL_SIDEBAR_CONTENT}`)
if (positions.top === 0 && positions.bottom === 0) { if (positions.top === 0 && positions.bottom === 0) {
@ -216,12 +227,22 @@ class ControlSidebar {
} else { } else {
$controlSidebar.css('top', heights.header) $controlSidebar.css('top', heights.header)
} }
if (footerFixed && navbarFixed) {
$controlsidebarContent.css('height', '100%')
$controlSidebar.css('height', '')
} else if (footerFixed || navbarFixed) {
$controlsidebarContent.css('height', '100%')
$controlsidebarContent.css('height', '')
}
} }
_fixHeight() { _fixHeight() {
const $body = $('body') const $body = $('body')
const $controlSidebar = $(`${this._config.target} ${SELECTOR_CONTROL_SIDEBAR_CONTENT}`)
if (!$body.hasClass(CLASS_NAME_LAYOUT_FIXED)) { if (!$body.hasClass(CLASS_NAME_LAYOUT_FIXED)) {
$controlSidebar.attr('style', '')
return return
} }
@ -233,19 +254,12 @@ class ControlSidebar {
let sidebarHeight = heights.window - heights.header let sidebarHeight = heights.window - heights.header
if ( if (this._isFooterFixed()) {
$body.hasClass(CLASS_NAME_FOOTER_FIXED) ||
$body.hasClass(CLASS_NAME_FOOTER_SM_FIXED) ||
$body.hasClass(CLASS_NAME_FOOTER_MD_FIXED) ||
$body.hasClass(CLASS_NAME_FOOTER_LG_FIXED) ||
$body.hasClass(CLASS_NAME_FOOTER_XL_FIXED)
) {
if ($(SELECTOR_FOOTER).css('position') === 'fixed') { if ($(SELECTOR_FOOTER).css('position') === 'fixed') {
sidebarHeight = heights.window - heights.header - heights.footer sidebarHeight = heights.window - heights.header - heights.footer
} }
} }
const $controlSidebar = $(`${this._config.target} ${SELECTOR_CONTROL_SIDEBAR_CONTENT}`)
$controlSidebar.css('height', sidebarHeight) $controlSidebar.css('height', sidebarHeight)
if (typeof $.fn.overlayScrollbars !== 'undefined') { if (typeof $.fn.overlayScrollbars !== 'undefined') {

Loading…
Cancel
Save