Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. export class Menu{
  2.  
  3. private static menu;
  4. private static detailsMenuContainer;
  5. private static state :boolean = false;
  6.  
  7. constructor(){
  8. Menu.menu = $(MENU);
  9. Menu.detailsMenuContainer = $(DETAILS_MENU_CONTAINER);
  10. fn.setOnDocumentListener('mousemove',MENU_EVENT_NAME,null,this.mousePosChecker);
  11. }
  12.  
  13. public static showMenu(){
  14. Menu.state = true;
  15. Menu.menu.prop('class',ACTIVE_MENU_STATE_CLASS);
  16. Menu.detailsMenuContainer.prop('class',ACTIVE_MENU_STATE_CLASS);
  17. }
  18.  
  19. public static hideMenu(){
  20. Menu.state = false;
  21. Menu.menu.prop('class',INACTIVE_MENU_STATE_CLASS);
  22. Menu.detailsMenuContainer.prop('class',INACTIVE_MENU_STATE_CLASS);
  23. }
  24.  
  25. private mousePosChecker(e){
  26. let posX = e.clientX, posY = e.clientY, controlStateSize = CONTROL_STATE_INACTIVE;
  27. if(Menu.state) controlStateSize = CONTROL_STATE_ACTIVE;
  28.  
  29. if(posY > CONTROL_TOP_STATE && posX < controlStateSize && !Menu.state){
  30. Menu.showMenu();
  31. }else if((posY < CONTROL_TOP_STATE || posX > controlStateSize) && Menu.state){
  32. Menu.hideMenu();
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement