Image switching on bool change [Answered]
Hello,
I have an image in a Blazor Server app that changes as a boolean value changes. The image flip happens, but the image flickers before being rendered to the screen. This only happens sometimes, so I figure it has something to do with the rendering speed. I am rendering it like so:
TLDR: image flickering on bool value change in blazor
7 Replies
It takes some time to request the image and display it. You could try caching the image in some way. I'm not aware of official ways to do it but you could try rendering it as 0x0 pixels or hiding it behind the first image
You can use a sprite sheet
Chris Coyier
CSS-Tricks
CSS Sprites: What They Are, Why They're Cool, and How To Use Them |...
This article has been revised and re-written several times since its very first publication in 2007, to keep the information current. The most recent revision
Went with hiding it, thanks
I also ran into this once, hiding helps indeed - Having two images on top of each other, showing the "flipped" one on demand instead of rendering it worked fine for me
sprites can help with load times as well
If this is complete don't forget to mark as answered
✅ This post has been marked as answered!