mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-08 17:59:09 +00:00
22 lines
654 B
TypeScript
22 lines
654 B
TypeScript
export const normalizeWheelDelta = (input: { deltaY: number; deltaMode: number; rootHeight: number }) => {
|
|
if (input.deltaMode === 1) return input.deltaY * 40
|
|
if (input.deltaMode === 2) return input.deltaY * input.rootHeight
|
|
return input.deltaY
|
|
}
|
|
|
|
export const shouldMarkBoundaryGesture = (input: {
|
|
delta: number
|
|
scrollTop: number
|
|
scrollHeight: number
|
|
clientHeight: number
|
|
}) => {
|
|
const max = input.scrollHeight - input.clientHeight
|
|
if (max <= 1) return true
|
|
if (!input.delta) return false
|
|
|
|
if (input.delta < 0) return input.scrollTop + input.delta <= 0
|
|
|
|
const remaining = max - input.scrollTop
|
|
return input.delta > remaining
|
|
}
|