Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

131
Vistas
Vue3 Move/drag image vertically

I have an image inside a wrapper div. I want to move the image vertically inside the div because the image does not fit. I found a few libs that do this in react but not many resources for Vue

I want to achieve a functionality like in Google Maps, where you can drag the map around. The map view always stays inside the wrapping container and the move extends only until the image top/bottom is reached

<script setup>
...
onMounted(() => {
    let bgDiv = document.getElementById("test");
    bgDiv.addEventListener('mousemove', e => {
      let y = e.offsetY;
      bgDiv.style.cssText = `transform: translate3d(0, ${y}px, 0)`;
    });
})
</script>

<div class="test" id="test">
        <svg
          version="1.1"
          xmlns="http://www.w3.org/2000/svg"
          xmlns:xlink="http://www.w3.org/1999/xlink"
          viewBox="0 0 1920 1080"
          preserveAspectRatio="xMinYMin meet"
          class="svg-content">
          <!-- overhead appears when viewbox > image, otherwise should be fine, so just make them match/fit  -->
          <image
            width="1920"
            height="1080"
            xlink:href="@/assets/background.gif"></image>
          <a class="cursor-pointer" data-bs-toggle="modal" data-bs-target="#">
            <rect
              x="618"
              y="140"
              fill="#fff"
              opacity="0.5"
              width="155"
              height="940"/>
          </a>
        </svg>
</div>
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda