sphinx-contrib / images

sphinxcontrib-images extension
Apache License 2.0
19 stars 16 forks source link

Disable white transition between image groups? #35

Closed rlaphoenix closed 1 year ago

rlaphoenix commented 1 year ago

Is it possible to disable the white flash during a transition of the LightBox2 backend?

https://user-images.githubusercontent.com/17136956/236823887-c1bb8c28-567f-440c-91e9-a65bf483e181.mp4

For image comparisons, it makes it more or less impossible to quickly snap back and forth and compare.

jonascj commented 1 year ago

Thank you for asking @rlaphoenix . You can change it. The transition is created by the lightbox2 script, so placing a few lines of custom javascript in your project should do the job:

Add a file _static/custom.js to your project with the following content:

lightbox.option({
    'imageFadeDuration' : 0
    });

All options are described here: https://lokeshdhakar.com/projects/lightbox2/#options . When changing image the new image still has to load, so maybe you'll still see a transition to solid white before chaning image. But eventually, chainging back and forth it should become instant since the images are now loaded.

I initially tested with the options 'imageFadeDuration' : 2000 and 'wrapAround': true since it was easy to spot the difference.

jonascj commented 1 year ago

This should be added to the documentation, thank you for asking!

rlaphoenix commented 1 year ago

While this works, I still occasionally get a flash of white (as if the image has not yet loaded), way after the images would have loaded. It's as if they are unloading the images and re-loading them again. Not ideal, but this still works better than before. Thanks.

jonascj commented 1 year ago

You're welcome. I see white flashes some times as well, even in my minimal example:

This is the example official lightbox2 example, with the fade duration set to zero and images replaced by local images (open index.html): lightbox2-2.11.4-example.zip

The white flashes I do see must be caused by the browser, the operating systems task scheduling or some such. I don't think it is a flaw in the lightbox2 library.

rlaphoenix commented 1 year ago

It is likely a browser auto-optimization thing going on. I will consider this solved. Thanks.