fix: add minimums & maximums for other settings

This commit is contained in:
qtchaos 2024-03-11 17:59:55 +02:00
parent 35c9c85b86
commit 7c5c5daf5c
No known key found for this signature in database
GPG Key ID: 7DA98B2B9EF06A90

View File

@ -67,9 +67,15 @@ export const useSubtitleStore = create(
updateStyling(newStyling) { updateStyling(newStyling) {
set((s) => { set((s) => {
if (newStyling.backgroundOpacity !== undefined) if (newStyling.backgroundOpacity !== undefined)
s.styling.backgroundOpacity = newStyling.backgroundOpacity; s.styling.backgroundOpacity = Math.min(
1,
Math.max(0, newStyling.backgroundOpacity),
);
if (newStyling.backgroundBlur !== undefined) if (newStyling.backgroundBlur !== undefined)
s.styling.backgroundBlur = Math.min(1, newStyling.backgroundBlur); s.styling.backgroundBlur = Math.min(
1,
Math.max(0, newStyling.backgroundBlur),
);
if (newStyling.color !== undefined) if (newStyling.color !== undefined)
s.styling.color = newStyling.color.toLowerCase(); s.styling.color = newStyling.color.toLowerCase();
if (newStyling.size !== undefined) if (newStyling.size !== undefined)