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

206
Visualizações
Mapbox mousemove Event Listener not Disabling

I'm using the mousemove event listener in mapbox to be able to drag a point around the map. However, when I'm calling .off() on it, it isn't disabling. I'm doing this in Angular with Typescript.

Original Call:

this.map.mapInstance.on('mousemove', this.onPointMove.bind(this));
this.map.mapInstance.once('mouseup', this.onPointUp.bind(this));

onPointMove(e):

const coords = e.lngLat;

this.map.mapInstance.getCanvasContainer().style.cursor = 'grabbing';

console.log(coords);

onPointUp(e):

this.map.mapInstance.getCanvasContainer().style.cursor = '';

this.map.mapInstance.off('mousemove', this.onPointMove.bind(this));

After I finish dragging, the console.log still gets outputted when I move my mouse around.

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

0

Your problem is you need to pass the exact same function to off, not a new function which does the same thing.

const mousemove = this.onPointMove.bind(this);
this.map.mapInstance.on('mousemove', mousemove);

// ...

this.map.mapInstance.off('mousemove', mousemove);
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