feat: 首页交互的

This commit is contained in:
2026-07-14 10:09:26 +08:00
parent b3a15eee9b
commit 515e02f3af
3 changed files with 203 additions and 5 deletions

View File

@@ -0,0 +1,42 @@
export const getDiscoveryPanelCollapseState = ({
currentScrollTop = 0,
lastScrollTop = 0,
isCollapsed = false,
threshold = 16,
directionThreshold = 2,
allowExpand = true,
}) => {
const current = Math.max(Number(currentScrollTop) || 0, 0);
const last = Math.max(Number(lastScrollTop) || 0, 0);
const delta = current - last;
if (delta > directionThreshold && current > threshold) {
return true;
}
if (allowExpand && delta < -directionThreshold) {
return false;
}
return isCollapsed;
};
export const canExpandDiscoveryPanelFromScroll = ({
isTouching = false,
touchDirection = "",
lastDownGestureAt = 0,
now = Date.now(),
gestureRetainMs = 800,
}) => {
if (isTouching) {
return touchDirection === "down";
}
const lastDownAt = Math.max(Number(lastDownGestureAt) || 0, 0);
if (!lastDownAt) {
return false;
}
const currentTime = Math.max(Number(now) || 0, 0);
return currentTime - lastDownAt <= gestureRetainMs;
};