02-events.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. var testLayout = [
  2. {"x":0,"y":0,"w":2,"h":2,"i":"0"},
  3. {"x":2,"y":0,"w":2,"h":4,"i":"1"},
  4. {"x":4,"y":0,"w":2,"h":5,"i":"2"},
  5. {"x":6,"y":0,"w":2,"h":3,"i":"3"},
  6. {"x":8,"y":0,"w":2,"h":3,"i":"4"},
  7. {"x":10,"y":0,"w":2,"h":3,"i":"5"},
  8. {"x":0,"y":5,"w":2,"h":5,"i":"6"},
  9. {"x":2,"y":5,"w":2,"h":5,"i":"7"},
  10. {"x":4,"y":5,"w":2,"h":5,"i":"8"},
  11. {"x":6,"y":4,"w":2,"h":4,"i":"9"},
  12. {"x":8,"y":4,"w":2,"h":4,"i":"10"},
  13. {"x":10,"y":4,"w":2,"h":4,"i":"11"},
  14. {"x":0,"y":10,"w":2,"h":5,"i":"12"},
  15. {"x":2,"y":10,"w":2,"h":5,"i":"13"},
  16. {"x":4,"y":8,"w":2,"h":4,"i":"14"},
  17. {"x":6,"y":8,"w":2,"h":4,"i":"15"},
  18. {"x":8,"y":10,"w":2,"h":5,"i":"16"},
  19. {"x":10,"y":4,"w":2,"h":2,"i":"17"},
  20. {"x":0,"y":9,"w":2,"h":3,"i":"18"},
  21. {"x":2,"y":6,"w":2,"h":2,"i":"19"}
  22. ];
  23. new Vue({
  24. el: '#app',
  25. data: {
  26. layout: testLayout,
  27. index: 0,
  28. eventLog: []
  29. },
  30. watch: {
  31. eventLog: function() {
  32. var eventsDiv = this.$refs.eventsDiv;
  33. eventsDiv.scrollTop = eventsDiv.scrollHeight;
  34. }
  35. },
  36. methods: {
  37. moveEvent: function(i, newX, newY){
  38. var msg = "MOVE i=" + i + ", X=" + newX + ", Y=" + newY;
  39. this.eventLog.push(msg);
  40. console.log(msg);
  41. },
  42. movedEvent: function(i, newX, newY){
  43. var msg = "MOVED i=" + i + ", X=" + newX + ", Y=" + newY;
  44. this.eventLog.push(msg);
  45. console.log(msg);
  46. },
  47. resizeEvent: function(i, newH, newW, newHPx, newWPx){
  48. var msg = "RESIZE i=" + i + ", H=" + newH + ", W=" + newW + ", H(px)=" + newHPx + ", W(px)=" + newWPx;
  49. this.eventLog.push(msg);
  50. console.log(msg);
  51. },
  52. resizedEvent: function(i, newX, newY, newHPx, newWPx){
  53. var msg = "RESIZED i=" + i + ", X=" + newX + ", Y=" + newY + ", H(px)=" + newHPx + ", W(px)=" + newWPx;
  54. this.eventLog.push(msg);
  55. console.log(msg);
  56. },
  57. containerResizedEvent: function(i, newH, newW, newHPx, newWPx){
  58. var msg = "CONTAINER RESIZED i=" + i + ", H=" + newH + ", W=" + newW + ", H(px)=" + newHPx + ", W(px)=" + newWPx;
  59. this.eventLog.push(msg);
  60. console.log(msg);
  61. },
  62. /**
  63. *
  64. * @param i the item id/index
  65. * @param newH new height in grid rows
  66. * @param newW new width in grid columns
  67. * @param newHPx new height in pixels
  68. * @param newWPx new width in pixels
  69. *
  70. */
  71. resizedEvent: function(i, newH, newW, newHPx, newWPx){
  72. var msg = "RESIZED i=" + i + ", H=" + newH + ", W=" + newW + ", H(px)=" + newHPx + ", W(px)=" + newWPx;
  73. this.eventLog.push(msg);
  74. console.log(msg);
  75. },
  76. layoutCreatedEvent: function(newLayout){
  77. this.eventLog.push("Created layout");
  78. console.log("Created layout: ", newLayout)
  79. },
  80. layoutBeforeMountEvent: function(newLayout){
  81. this.eventLog.push("beforeMount layout");
  82. console.log("beforeMount layout: ", newLayout)
  83. },
  84. layoutMountedEvent: function(newLayout){
  85. this.eventLog.push("Mounted layout");
  86. console.log("Mounted layout: ", newLayout)
  87. },
  88. layoutReadyEvent: function(newLayout){
  89. this.eventLog.push("Ready layout");
  90. console.log("Ready layout: ", newLayout)
  91. },
  92. layoutUpdatedEvent: function(newLayout){
  93. this.eventLog.push("Updated layout");
  94. console.log("Updated layout: ", newLayout)
  95. },
  96. }
  97. });