Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. <!-- my context menu -->
  2. <ul class="context-menu"
  3. ref="contextMenuTrack"
  4. v-if="openedMenu === 'contextMenuTrack'"
  5. v-bind:style="{top: top, left: left}"
  6. v-on:blur="closeMenu()">
  7. <li v-on:click="removeTrack(project.structure.tracks.indexOf(targetOfMenu));closeMenu()">delete track</li>
  8. </ul>
  9. <div>
  10.  
  11. [ ...... stuff here ......]
  12.  
  13. <!-- Where the menu is called-->
  14. <li class="track"
  15. v-for="track in project.structure.tracks">
  16. <div class="track-name-row">
  17. <li @contextmenu.prevent="openContextMenuTrack(track,$event)"
  18. v-on:click="expandTrack(project.structure.tracks.indexOf(track))"
  19. class="track-color-viewer"></li>
  20.  
  21. [ .... other li tags .....]
  22. </div>
  23. </li>
  24.  
  25. [ ...... stuff here ......]
  26.  
  27. </div>
  28.  
  29. data() {
  30. return {
  31. //the kind of menu which is opened
  32. openedMenu: undefined,
  33. //the coordinate of the menu
  34. top: "0px",
  35. left: "0px",
  36. //the element which is targeted by the menu
  37. targetOfMenu: undefined
  38. };
  39. },
  40.  
  41. methods: {
  42.  
  43. setMenu(top, left) {
  44. this.top = top - 170 + "px";
  45. this.left = left + "px";
  46. },
  47.  
  48. // opening menu : calling set menu whith x and y
  49. openContextMenuTrack(track, event) {
  50. this.openedMenu = "contextMenuTrack";
  51. this.targetOfMenu = track;
  52.  
  53. this.$nextTick((() => {
  54. this.$refs.contextMenuTrack.focus();
  55. this.setMenu(event.y, event.x);
  56. }).bind(this));
  57. },
  58.  
  59. closeMenu() {
  60. this.openedMenu = undefined;
  61. this.targetOfMenu = undefined;
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement