5180 fichiers 38.5 Mo 0 téléchargements 242 vues mis à jour il y a 5 heures ui
nitro-v36-with-renderer-v36 / src / common / scroll-area / classicScrollbar.helpers.ts
classicScrollbar.helpers.ts 927 o Télécharger le fichier
export interface ClassicScrollbarMetrics {
    overflow: boolean;
    thumbSize: number;
    thumbOffset: number;
}

export const getClassicScrollbarMetrics = (scrollHeight: number, clientHeight: number, trackHeight: number, scrollTop: number, minThumbSize = 12): ClassicScrollbarMetrics => {
    if (scrollHeight <= clientHeight || clientHeight <= 0 || trackHeight <= 0) {
        return { overflow: false, thumbSize: Math.max(0, trackHeight), thumbOffset: 0 };
    }

    const thumbSize = Math.max(minThumbSize, Math.min(trackHeight, Math.round((trackHeight * clientHeight) / scrollHeight)));
    const maxScroll = scrollHeight - clientHeight;
    const maxThumbOffset = trackHeight - thumbSize;
    const normalizedScrollTop = Math.max(0, Math.min(maxScroll, scrollTop));

    return {
        overflow: true,
        thumbSize,
        thumbOffset: Math.round((normalizedScrollTop / maxScroll) * maxThumbOffset)
    };
};
15Sujets
1Dépôts
20Membres
2En ligne
Profile
Inscrit
Dernière visite
Messages
0
Votes positifs
0
Votes négatifs
0

Nous utilisons des cookies pour assurer le bon fonctionnement du site et améliorer votre expérience. en savoir plus

Autoriser