v2.5.1更新
This commit is contained in:
@@ -337,25 +337,40 @@ function toggleActionDropdown(el) {
|
||||
|
||||
var isOpen = menu.classList.contains('show');
|
||||
// 先关闭所有
|
||||
document.querySelectorAll('.action-dropdown-menu.show').forEach(function(m) {
|
||||
m.classList.remove('show');
|
||||
var toggle = m.closest('.action-dropdown').querySelector('.action-dropdown-toggle');
|
||||
if (toggle) toggle.classList.remove('open');
|
||||
});
|
||||
closeAllDropdowns();
|
||||
|
||||
if (!isOpen) {
|
||||
// 使用 fixed 定位,避免被 overflow 容器裁剪
|
||||
var rect = el.getBoundingClientRect();
|
||||
menu.style.position = 'fixed';
|
||||
menu.style.bottom = 'auto';
|
||||
menu.style.right = 'auto';
|
||||
menu.style.left = rect.right - 120 + 'px'; // 120px = min-width
|
||||
menu.style.top = (rect.top - 4) + 'px';
|
||||
menu.style.transform = 'translateY(-100%)';
|
||||
menu.classList.add('show');
|
||||
el.classList.add('open');
|
||||
}
|
||||
}
|
||||
|
||||
function closeAllDropdowns() {
|
||||
document.querySelectorAll('.action-dropdown-menu.show').forEach(function(m) {
|
||||
m.classList.remove('show');
|
||||
m.style.position = '';
|
||||
m.style.left = '';
|
||||
m.style.top = '';
|
||||
m.style.transform = '';
|
||||
var toggle = m.closest('.action-dropdown');
|
||||
if (toggle) {
|
||||
var btn = toggle.querySelector('.action-dropdown-toggle');
|
||||
if (btn) btn.classList.remove('open');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('click', function(e) {
|
||||
if (!e.target.closest('.action-dropdown')) {
|
||||
document.querySelectorAll('.action-dropdown-menu.show').forEach(function(m) {
|
||||
m.classList.remove('show');
|
||||
var toggle = m.closest('.action-dropdown').querySelector('.action-dropdown-toggle');
|
||||
if (toggle) toggle.classList.remove('open');
|
||||
});
|
||||
closeAllDropdowns();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user