Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

349 B
Raw Blame
export const getScrollIndexFromPointer = (
    clientY: number,
    rect: Pick<DOMRect, "top" | "height">,
    min: number,
    max: number,
) => {
    if (max <= min || rect.height <= 0) {
        return min;
    }
    const ratio = Math.min(1, Math.max(0, (clientY - rect.top) / rect.height));
    return Math.round(min + (max - min) * ratio);
};