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

213
Vistas
Clamp panning to svg boundaries with panzoom.svg.js

In the following code, I set up margins so that it would not be able to pan outside of the svg boundaries as follows:

const map = SVG('#map')
        .size(500, 500)
        // @ts-ignore: next-line
        .panZoom({
          zoomMin: 1,
          margins: {
            top: 500,
            left: 500,
            bottom: 500,
            right: 500,
          },
        })
        .zoom(1);

I thought that I could adjust adjust the margins in the zoom callback by multiplying the values with the zoom level, but that does not work and causes the panning to stop working:

map.on('zoom', event => {
 const { level } = event.detail
 map.panZoom({
  margins: {
    top: 500 * level,
    left: 500 * level,
    bottom: 500 * level,
    right: 500 * level
   }
 })
})
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