Capture drag on mobile or mouse move events on pc


#1

I’m building an application that connects to my smart TV in order to remote control it.

I just want to add an area where you can move your mouse (or move your finger) that updates the pointer coordinates in the TV.

I can’t find anything related to it with ionic 2. Any clues where to read documentation about it?

Best,


#2

What is question? Get the move coordinates? Move event returns the event object with coordinates.


#3

Hey @xr0master, sry If I didn’t explain myself.

In the Events doc I can’t find anything related to mouse events or any other event: http://ionicframework.com/docs/v2/api/util/Events/

So, it’s not clear for me to which kind of event I need to subscribe in order to get touch/move coordinates.


#4

Ah )
Events there are EventEmitter. You no need it. You need use just the javascript events.
Something…

<div (move)="somethingMoved($event)"></div>
@Component(...)
class MyComponent {
  somethingMoved(event) {
    console.log(event);
  }
}

Update: Fixed my terrible English


#5

Thanks for the reply :slight_smile:

That didn’t worked. It works for (click) but it is not working for (move)

@Component({
  selector: 'tv-area',
  template: '<div (move)="test($event)" style="background-color: red;">foobar</div>'
})
export class TvAreaComponent {
  constructor() {}

  test(event) {
    console.log(event);
  }
}

#6

I made a mistake.

mousemove


#7

Uffff… now I understand what you meant at the beggining… I was thinking off the window…

This has to do with angular 2 managing events and not ionic. Sry, my bad when I got confused with Events api.

Thanks,


#8

Hey just wanted to chime in on this a bit.

So if you wanted to bind to an event in angular to, all you need to do is use the (eventName)