Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5d3905632d |
@@ -345,48 +345,31 @@
|
|||||||
return target.closest('.ss-content, .ss-list');
|
return target.closest('.ss-content, .ss-list');
|
||||||
};
|
};
|
||||||
|
|
||||||
const getOpenDropdown = () => {
|
|
||||||
const openContent = document.querySelector('.ss-content.ss-open');
|
|
||||||
|
|
||||||
if (openContent) {
|
|
||||||
return openContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
const openMain = document.querySelector('.ss-main.ss-open');
|
|
||||||
|
|
||||||
if (!openMain) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const scope = openMain.parentElement || document;
|
|
||||||
return scope.querySelector('.ss-content');
|
|
||||||
};
|
|
||||||
|
|
||||||
const getScrollContainer = (targetDropdown) => {
|
const getScrollContainer = (targetDropdown) => {
|
||||||
const openDropdown = getOpenDropdown();
|
if (!targetDropdown) {
|
||||||
|
|
||||||
if (!openDropdown) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!targetDropdown) {
|
if (targetDropdown.scrollHeight > targetDropdown.clientHeight) {
|
||||||
return openDropdown;
|
return targetDropdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
const contentContainer = targetDropdown.closest('.ss-content');
|
const contentContainer = targetDropdown.closest('.ss-content') || targetDropdown;
|
||||||
return contentContainer || openDropdown;
|
const listContainer = contentContainer.querySelector('.ss-list');
|
||||||
|
|
||||||
|
if (listContainer && listContainer.scrollHeight > listContainer.clientHeight) {
|
||||||
|
return listContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (contentContainer.scrollHeight > contentContainer.clientHeight) {
|
||||||
|
return contentContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const shouldBlockBoundaryScroll = (scrollContainer, delta) => {
|
const shouldBlockBoundaryScroll = (scrollContainer, delta) => {
|
||||||
if (!scrollContainer) {
|
if (!scrollContainer || delta === 0) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scrollContainer.scrollHeight <= scrollContainer.clientHeight) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (delta === 0) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,12 +387,12 @@
|
|||||||
|
|
||||||
document.addEventListener('wheel', (event) => {
|
document.addEventListener('wheel', (event) => {
|
||||||
const dropdown = getDropdownFromTarget(event.target);
|
const dropdown = getDropdownFromTarget(event.target);
|
||||||
const scrollContainer = getScrollContainer(dropdown);
|
if (!dropdown) {
|
||||||
|
|
||||||
if (!scrollContainer) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const scrollContainer = getScrollContainer(dropdown);
|
||||||
|
|
||||||
if (shouldBlockBoundaryScroll(scrollContainer, event.deltaY)) {
|
if (shouldBlockBoundaryScroll(scrollContainer, event.deltaY)) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
@@ -419,9 +402,7 @@
|
|||||||
|
|
||||||
document.addEventListener('touchstart', (event) => {
|
document.addEventListener('touchstart', (event) => {
|
||||||
const dropdown = getDropdownFromTarget(event.target);
|
const dropdown = getDropdownFromTarget(event.target);
|
||||||
const scrollContainer = getScrollContainer(dropdown);
|
if (!dropdown || event.touches.length === 0) {
|
||||||
|
|
||||||
if (!scrollContainer || event.touches.length === 0) {
|
|
||||||
lastTouchY = null;
|
lastTouchY = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -431,9 +412,13 @@
|
|||||||
|
|
||||||
document.addEventListener('touchmove', (event) => {
|
document.addEventListener('touchmove', (event) => {
|
||||||
const dropdown = getDropdownFromTarget(event.target);
|
const dropdown = getDropdownFromTarget(event.target);
|
||||||
|
if (!dropdown || event.touches.length === 0 || lastTouchY === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const scrollContainer = getScrollContainer(dropdown);
|
const scrollContainer = getScrollContainer(dropdown);
|
||||||
|
|
||||||
if (!scrollContainer || event.touches.length === 0 || lastTouchY === null) {
|
if (!scrollContainer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user