5180 fichiers 38.5 Mo 0 téléchargements 271 vues mis à jour il y a 6 heures ui
nitro-v36-with-renderer-v36 / src / api / room / widgets / GetBotSkillWindowPosition.ts
GetBotSkillWindowPosition.ts 810 o Télécharger le fichier
export interface BotSkillWindowAnchor {
    x: number;
    y: number;
    width: number;
}

/** BotSkillConfigurationViewBase.open + fitToScreen: centred on the bot, bottom on its head, kept fully on screen. */
export const GetBotSkillWindowPosition = (
    anchor: BotSkillWindowAnchor | null,
    width: number,
    height: number,
    viewportWidth: number,
    viewportHeight: number
): { x: number; y: number } => {
    const maxX = Math.max(0, viewportWidth - width);
    const maxY = Math.max(0, viewportHeight - height);

    if (!anchor) return { x: Math.round(maxX / 2), y: Math.round(maxY / 2) };

    const x = Math.round(anchor.x + anchor.width / 2 - width / 2);
    const y = Math.round(anchor.y - height);

    return { x: Math.min(Math.max(0, x), maxX), y: Math.min(Math.max(0, y), maxY) };
};
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