Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

134
Visualizações
How to switch between two images instantly?

I have a drawer that serves as a menu. There is an image on top and icons on the bottom. When the user hovers over the drawer, it expands to show a larger image and icons with text.

My problem is: during this enlargement transition, the first image enlarges (Not good) and stays for 1 ~ 5 seconds then, gives way to the second one.

I would like to make it so that when the user hovers over the drawer the first image is hidden immediately to make room for the second. I want this "delay" to be removed.

(The fact that the menu does not react immediately when you hover is another problem ^^)

Here is a gif of the problem : https://gyazo.com/064245b3bc87cabf6ffa62b51c506025

And this is the code that I use to switch between these 2 images :

 <a href={'/'} className={'brand'}>
{sideWidth >= 200 ?
<img src={'/images/SI_Infra.svg'} className={"logoHub"} alt={"Logo Si infra"} href={'/'}/> 
    :
<img src='/images/SI.svg' className={"logoHub"} alt={"Logo Si infra"} />
}
</a>

Is there an easier or "faster" way to make this image transition?

(Or maybe the problem is with my PC (It's local))

If you need more visible code tell me.

EDIT :

With the help and advise of all members, the problem is solved ! The code :

            <a href={'/'} className={'brand'}>
                {sideWidth >= 200 ?
                <>
                  <img src={'/images/SI_Infra.svg'} className={"logoHub"} alt={"Logo Si infra"} href={'/'}/>
                  <img src={'/images/SI.svg'} className={"logoHub"} alt={"Logo Si infra"} style={{display:'none'}} />
                </>
                    :
                <>
                  <img src={'/images/SI_Infra.svg'} className={"logoHub"} alt={"Logo Si infra"} href={'/'} style={{display:'none'}}/>
                  <img src={'/images/SI.svg'} className={"logoHub"} alt={"Logo Si infra"} />
                </>
                }
            </a>

As Maxdola advised me, I render both images but decide to hide one with "display: 'none'". This may not be the best solution but it solves my problem! Thanks a lot !

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The problem is you are re-rendering the image and because of that the browser then downloads the image.

You should render both images, but make one Invisible.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda