Fixed sidebar navigation on second scroll
This commit is contained in:
20
dist/js/adminlte.js
vendored
20
dist/js/adminlte.js
vendored
@@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* AdminLTE v4.0.0-rc3 (https://adminlte.io)
|
||||
* AdminLTE v4.0.0-rc4 (https://adminlte.io)
|
||||
* Copyright 2014-2025 Colorlib <https://colorlib.com>
|
||||
* Licensed under MIT (https://github.com/ColorlibHQ/AdminLTE/blob/master/LICENSE)
|
||||
*/
|
||||
@@ -641,8 +641,14 @@
|
||||
const sidebar = document.getElementsByClassName(sidebarExpand)[0];
|
||||
const sidebarContent = globalThis.getComputedStyle(sidebar, '::before').getPropertyValue('content');
|
||||
this._config = { ...this._config, sidebarBreakpoint: Number(sidebarContent.replace(/[^\d.-]/g, '')) };
|
||||
// FIXED: Don't auto-collapse on mobile if sidebar is currently open
|
||||
// This prevents resize events (triggered by scrolling) from closing the sidebar
|
||||
const isCurrentlyOpen = document.body.classList.contains(CLASS_NAME_SIDEBAR_OPEN);
|
||||
if (window.innerWidth <= this._config.sidebarBreakpoint) {
|
||||
this.collapse();
|
||||
// Only collapse if not currently open (prevents scroll-triggered closes)
|
||||
if (!isCurrentlyOpen) {
|
||||
this.collapse();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!document.body.classList.contains(CLASS_NAME_SIDEBAR_MINI)) {
|
||||
@@ -682,20 +688,22 @@
|
||||
const sidebarOverlay = document.createElement('div');
|
||||
sidebarOverlay.className = CLASS_NAME_SIDEBAR_OVERLAY;
|
||||
document.querySelector(SELECTOR_APP_WRAPPER)?.append(sidebarOverlay);
|
||||
let isTouchMoved = false;
|
||||
let overlayTouchMoved = false;
|
||||
// Handle touch events on overlay (area outside sidebar)
|
||||
sidebarOverlay.addEventListener('touchstart', () => {
|
||||
isTouchMoved = false;
|
||||
overlayTouchMoved = false;
|
||||
}, { passive: true });
|
||||
sidebarOverlay.addEventListener('touchmove', () => {
|
||||
isTouchMoved = true;
|
||||
overlayTouchMoved = true;
|
||||
}, { passive: true });
|
||||
sidebarOverlay.addEventListener('touchend', event => {
|
||||
if (!isTouchMoved) {
|
||||
if (!overlayTouchMoved) {
|
||||
event.preventDefault();
|
||||
const target = event.currentTarget;
|
||||
const data = new PushMenu(target, Defaults);
|
||||
data.collapse();
|
||||
}
|
||||
overlayTouchMoved = false;
|
||||
}, { passive: false });
|
||||
sidebarOverlay.addEventListener('click', event => {
|
||||
event.preventDefault();
|
||||
|
||||
2
dist/js/adminlte.js.map
vendored
2
dist/js/adminlte.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/js/adminlte.min.js
vendored
4
dist/js/adminlte.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/adminlte.min.js.map
vendored
2
dist/js/adminlte.min.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user