Add option for instant transitions in lightbox (#6354)

This commit is contained in:
hckrman101 2025-12-01 22:25:46 -05:00 committed by GitHub
parent 5f16547e58
commit 69fd073d5d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 40 additions and 1 deletions

View file

@ -339,6 +339,7 @@ input ConfigImageLightboxInput {
resetZoomOnNav: Boolean resetZoomOnNav: Boolean
scrollMode: ImageLightboxScrollMode scrollMode: ImageLightboxScrollMode
scrollAttemptsBeforeChange: Int scrollAttemptsBeforeChange: Int
disableAnimation: Boolean
} }
type ConfigImageLightboxResult { type ConfigImageLightboxResult {
@ -348,6 +349,7 @@ type ConfigImageLightboxResult {
resetZoomOnNav: Boolean resetZoomOnNav: Boolean
scrollMode: ImageLightboxScrollMode scrollMode: ImageLightboxScrollMode
scrollAttemptsBeforeChange: Int! scrollAttemptsBeforeChange: Int!
disableAnimation: Boolean
} }
input ConfigInterfaceInput { input ConfigInterfaceInput {

View file

@ -493,6 +493,8 @@ func (r *mutationResolver) ConfigureInterface(ctx context.Context, input ConfigI
r.setConfigString(config.ImageLightboxScrollModeKey, (*string)(options.ScrollMode)) r.setConfigString(config.ImageLightboxScrollModeKey, (*string)(options.ScrollMode))
r.setConfigInt(config.ImageLightboxScrollAttemptsBeforeChange, options.ScrollAttemptsBeforeChange) r.setConfigInt(config.ImageLightboxScrollAttemptsBeforeChange, options.ScrollAttemptsBeforeChange)
r.setConfigBool(config.ImageLightboxDisableAnimation, options.DisableAnimation)
} }
if input.CSS != nil { if input.CSS != nil {

View file

@ -209,6 +209,7 @@ const (
ImageLightboxResetZoomOnNav = "image_lightbox.reset_zoom_on_nav" ImageLightboxResetZoomOnNav = "image_lightbox.reset_zoom_on_nav"
ImageLightboxScrollModeKey = "image_lightbox.scroll_mode" ImageLightboxScrollModeKey = "image_lightbox.scroll_mode"
ImageLightboxScrollAttemptsBeforeChange = "image_lightbox.scroll_attempts_before_change" ImageLightboxScrollAttemptsBeforeChange = "image_lightbox.scroll_attempts_before_change"
ImageLightboxDisableAnimation = "image_lightbox.disable_animation"
UI = "ui" UI = "ui"
@ -1296,6 +1297,10 @@ func (i *Config) GetImageLightboxOptions() ConfigImageLightboxResult {
if v := i.with(ImageLightboxScrollAttemptsBeforeChange); v != nil { if v := i.with(ImageLightboxScrollAttemptsBeforeChange); v != nil {
ret.ScrollAttemptsBeforeChange = v.Int(ImageLightboxScrollAttemptsBeforeChange) ret.ScrollAttemptsBeforeChange = v.Int(ImageLightboxScrollAttemptsBeforeChange)
} }
if v := i.with(ImageLightboxDisableAnimation); v != nil {
value := v.Bool(ImageLightboxDisableAnimation)
ret.DisableAnimation = &value
}
return ret return ret
} }

View file

@ -13,6 +13,7 @@ type ConfigImageLightboxResult struct {
ResetZoomOnNav *bool `json:"resetZoomOnNav"` ResetZoomOnNav *bool `json:"resetZoomOnNav"`
ScrollMode *ImageLightboxScrollMode `json:"scrollMode"` ScrollMode *ImageLightboxScrollMode `json:"scrollMode"`
ScrollAttemptsBeforeChange int `json:"scrollAttemptsBeforeChange"` ScrollAttemptsBeforeChange int `json:"scrollAttemptsBeforeChange"`
DisableAnimation *bool `json:"disableAnimation"`
} }
type ImageLightboxDisplayMode string type ImageLightboxDisplayMode string

View file

@ -100,6 +100,7 @@ fragment ConfigInterfaceData on ConfigInterfaceResult {
resetZoomOnNav resetZoomOnNav
scrollMode scrollMode
scrollAttemptsBeforeChange scrollAttemptsBeforeChange
disableAnimation
} }
disableDropdownCreate { disableDropdownCreate {
performer performer

View file

@ -599,6 +599,13 @@ export const SettingsInterfacePanel: React.FC = PatchComponent(
saveLightboxSettings({ scrollAttemptsBeforeChange: v }) saveLightboxSettings({ scrollAttemptsBeforeChange: v })
} }
/> />
<BooleanSetting
id="lightbox_disable_animation"
headingID="dialogs.lightbox.disable_animation"
checked={iface.imageLightbox?.disableAnimation ?? false}
onChange={(v) => saveLightboxSettings({ disableAnimation: v })}
/>
</SettingSection> </SettingSection>
<SettingSection headingID="config.ui.detail.heading"> <SettingSection headingID="config.ui.detail.heading">

View file

@ -200,6 +200,8 @@ export const LightboxComponent: React.FC<IProps> = ({
config?.interface.imageLightbox.scrollAttemptsBeforeChange ?? 0 config?.interface.imageLightbox.scrollAttemptsBeforeChange ?? 0
); );
const disableAnimation = config?.interface.imageLightbox.disableAnimation;
function setSlideshowDelay(v: number) { function setSlideshowDelay(v: number) {
setLightboxSettings({ slideshowDelay: v }); setLightboxSettings({ slideshowDelay: v });
} }
@ -340,6 +342,10 @@ export const LightboxComponent: React.FC<IProps> = ({
(isUserAction = true) => { (isUserAction = true) => {
if (isSwitchingPage || index === -1) return; if (isSwitchingPage || index === -1) return;
if (disableAnimation) {
setInstant();
}
setShowChapters(false); setShowChapters(false);
setMovingLeft(true); setMovingLeft(true);
@ -357,13 +363,25 @@ export const LightboxComponent: React.FC<IProps> = ({
resetIntervalCallback.current(); resetIntervalCallback.current();
} }
}, },
[images, pageCallback, isSwitchingPage, resetIntervalCallback, index] [
images,
pageCallback,
isSwitchingPage,
resetIntervalCallback,
index,
disableAnimation,
setInstant,
]
); );
const handleRight = useCallback( const handleRight = useCallback(
(isUserAction = true) => { (isUserAction = true) => {
if (isSwitchingPage) return; if (isSwitchingPage) return;
if (disableAnimation) {
setInstant();
}
setMovingLeft(false); setMovingLeft(false);
setShowChapters(false); setShowChapters(false);
@ -388,6 +406,8 @@ export const LightboxComponent: React.FC<IProps> = ({
isSwitchingPage, isSwitchingPage,
resetIntervalCallback, resetIntervalCallback,
index, index,
disableAnimation,
setInstant,
] ]
); );

View file

@ -938,6 +938,7 @@
}, },
"lightbox": { "lightbox": {
"delay": "Delay (Sec)", "delay": "Delay (Sec)",
"disable_animation": "Disable transition animation between images",
"display_mode": { "display_mode": {
"fit_horizontally": "Fit horizontally", "fit_horizontally": "Fit horizontally",
"fit_to_screen": "Fit to screen", "fit_to_screen": "Fit to screen",