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

254
Visualizações
How to make a draggable image appear on link hover?

How to make a draggable image appear on link hover? Just like in this website

I will post some more images: enter image description here

enter image description here enter image description here

I am using React, so if it works with a library, i will be happy to take recommendations

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

0

You must present what you have done till now, so we can help. consider this for your next questions. Btw you can use something like this:

document.querySelectorAll(".item").forEach((element) => {
  element.addEventListener("mousemove", (e) => {
    const img = e.currentTarget.querySelector("img");
    const {
      x,
      y,
      width,
      height
    } = e.currentTarget.getBoundingClientRect();
    img.style.display = "block";
    img.style.transform = `translate(${e.pageX - img.clientWidth / 2 - x}px,${
      e.pageY - img.clientHeight / 2 - y
    }px)`;

    if (
      e.pageX > width + x ||
      e.pageY > height + y ||
      e.pageX < x ||
      e.pageY < y
    ) {
      img.style.display = "none";
    }
  });

  element.addEventListener("mouseleave", (e) => {
    const img = e.currentTarget.querySelector("img");
    img.style.display = "none";
  });
});
.item {
  display: block;
  position: relative;
  background-color: tomato;
}

* {
  padding: 0;
  margin: 0;
}

body {
  padding-top: 50px;
}

a {
  text-decoration: none;
  color: black;
  font-size: 2rem;
}

a:active,
a:focus,
a:hover {
  cursor: none;
}

.title {
  overflow: hidden;
  max-width: 100%;
}

.item img {
  display: none;
  max-width: 220px;
  position: absolute;
  top: 0;
  left: 0;
}

.item {
  margin-top: 20px;
  background-color: cadetblue;
}
<a class="item" href="#">
  <h3 class="title">Title</h3>
  <img src="https://kulbachny.com/wp-content/uploads/2021/01/jg-cosmos.jpg" />
</a>

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