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

119
Visualizações
Mouse wheel directive is not called in Angular 13

I am trying to use mouse wheel directive. This is my first directive, and I can't make it work. This is the directive:

import { Directive, ElementRef, HostListener } from "@angular/core";

@Directive({
  selector: '[wheel]'
})
export class MouseWheelDirective {

  constructor(private el: ElementRef) {
    console.log("directive was created");
  }

  @HostListener('mousewheel', ['$event'])
  onMousewheel(event) {
    console.log("event");
    if (event.wheelDelta > 0) {
      console.log("wheel 0");
    }
    if (event.wheelDelta < 0) {
      console.log("wheel 1");
    }
  }
}

And this is how I use it:

<div #htmlDiv wheel class="data-table">
    <table mat-table [dataSource]="dataSource">
        ...
    </table>
</div>

I registered directive in NgModule:

@NgModule({
  declarations: [
    ...
    MouseWheelDirective
  ],
  imports: [
    ...
  ],
  exports: [
    ...
    MouseWheelDirective
  ]
})

In console I see directive was created. But I don't see any messages when I'm scrolling mouse wheel on my table. Could anyone say how to fix it?

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

0

'mousewheel' is deprecated. Use 'wheel' instead. Here is a list of HTML DOM events: https://www.w3schools.com/jsref/dom_obj_event.asp

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