mouse.js 466 B

123456789101112131415161718192021222324252627282930
  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. console.log(this)
  9. this.container.addEventListener('mousedown',(e) => {
  10. switch(e.button){
  11. case 0:
  12. this.emit('LeftDown',e);
  13. break;
  14. case 2:
  15. this.emit('RightDown',e);
  16. break;
  17. default:
  18. console.log('sss')
  19. break;
  20. }
  21. })
  22. return this;
  23. }
  24. }