I am trying to create a listener on a component attached to either mousedown (for desktops) and touchstart (for mobile)
this.renderer.listen(this.el.nativeElement, 'mousedown touchstart', (event: any) => {}
However, when I run it like above it doesn't work. When I have 1 option (either mousedown or touchstart) it working fine for given event type, however as soon as I add the second option it doesn't react at all.
It's not supported via Renderer2
. See: https://github.com/angular/angular/issues/12751
Use this:
Observable.merge(
Observable.fromEvent(this.el.nativeElement, 'mousedown'),
Observable.fromEvent(this.el.nativeElement, 'touchstart')
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With