Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. interface EventEmitter<T extends Function> {
  2.     on: T;
  3. }
  4.  
  5. type MouseType = 'mousedown' | 'mouseup';
  6. type TouchType = 'touchstart' | 'touchend';
  7. type MouseOn = (m: MouseType, e: (e: MouseEvent) => void) => void;
  8. type TouchOn = (m: TouchType, e: (e: TouchEvent) => void) => void;
  9. let noop: any = () => { };
  10.  
  11. class AABB implements EventEmitter<MouseOn&TouchOn> {
  12.     on: MouseOn & TouchOn = noop;
  13. }
  14.  
  15. let aabb = new AABB();
  16.  
  17. aabb.on('mousedown', (param: MouseEvent) => {
  18.    
  19. })
  20. aabb.on('touchstart', (param: TouchEvent) => {
  21.    
  22. })
  23. aabb.on('mousedown', (param: TouchEvent) => {
  24.    
  25. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement