mouse.js 446 B

1234567891011121314151617181920212223242526272829
  1. import EventSystem from './EventSystem';
  2. export default class Mouse extends EventSystem{
  3. constructor(container = window){
  4. super()
  5. this.container = container;
  6. }
  7. listen(){
  8. this.container.addEventListener('mousedown',(e) => {
  9. switch(e.button){
  10. case 0:
  11. this.emit('LeftDown',e);
  12. break;
  13. case 2:
  14. this.emit('RightDown',e);
  15. break;
  16. default:
  17. console.log('sss')
  18. break;
  19. }
  20. })
  21. return this;
  22. }
  23. }