04-allow-ignore.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Vue Grid Layout Example 4 - Drag allow/ignore elements</title>
  6. <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
  7. <!--<link rel="stylesheet" href="../dist/vue-grid-layout.css">-->
  8. <link rel="stylesheet" href="app.css">
  9. </head>
  10. <body>
  11. <h1>Vue Grid Layout Example 4 - Drag allow/ignore elements</h1>
  12. <a href="https://github.com/jbaysolutions/vue-grid-layout">View project on Github</a>
  13. <br/>
  14. <a href="03-multiple-grids.html">Previous example: Multiple grids</a>
  15. <br/>
  16. <a href="05-mirrored.html">Next example: Mirrored grid layout</a>
  17. <div id="app" style="width: 100%;">
  18. <!--<pre>{{ $data | json }}</pre>-->
  19. <div>
  20. <br/>
  21. Ignore drag on certain elements and allow on on others.
  22. <br/>
  23. Click and drag the dots on the corner of each item to reposition
  24. <div class="layoutJSON">
  25. Displayed as <code>[x, y, w, h]</code>:
  26. <div class="columns">
  27. <div class="layoutItem" v-for="item in layout">
  28. <b>{{item.i}}</b>: [{{item.x}}, {{item.y}}, {{item.w}}, {{item.h}}]
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. <div id="content">
  34. <!--<button @click="addItem">Add an item</button>-->
  35. <grid-layout :layout="layout"
  36. :col-num="12"
  37. :row-height="30"
  38. :is-draggable="true"
  39. :is-resizable="true"
  40. :vertical-compact="true"
  41. :use-css-transforms="true"
  42. >
  43. <grid-item v-for="item in layout"
  44. :x="item.x"
  45. :y="item.y"
  46. :w="item.w"
  47. :h="item.h"
  48. :i="item.i"
  49. drag-allow-from=".vue-draggable-handle"
  50. drag-ignore-from=".no-drag"
  51. >
  52. <div class="text">
  53. <div class="vue-draggable-handle"></div>
  54. <div class="no-drag">
  55. <span>{{item.i}}</span>
  56. <br/>
  57. <button>test</button>
  58. </div>
  59. </div>
  60. </grid-item>
  61. </grid-layout>
  62. </div>
  63. </div>
  64. <script src="vue.min.js"></script>
  65. <script src="../dist/vue-grid-layout.umd.min.js"></script>
  66. <script type="text/javascript">
  67. new Vue({
  68. el: '#app',
  69. data: {
  70. layout: [
  71. {"x":0,"y":0,"w":2,"h":2,"i":"0"},
  72. {"x":2,"y":0,"w":2,"h":4,"i":"1"},
  73. {"x":4,"y":0,"w":2,"h":5,"i":"2"},
  74. {"x":6,"y":0,"w":2,"h":3,"i":"3"},
  75. {"x":8,"y":0,"w":2,"h":3,"i":"4"},
  76. {"x":10,"y":0,"w":2,"h":3,"i":"5"},
  77. {"x":0,"y":5,"w":2,"h":5,"i":"6"},
  78. {"x":2,"y":5,"w":2,"h":5,"i":"7"},
  79. {"x":4,"y":5,"w":2,"h":5,"i":"8"},
  80. {"x":6,"y":4,"w":2,"h":4,"i":"9"},
  81. {"x":8,"y":4,"w":2,"h":4,"i":"10"},
  82. {"x":10,"y":4,"w":2,"h":4,"i":"11"},
  83. {"x":0,"y":10,"w":2,"h":5,"i":"12"},
  84. {"x":2,"y":10,"w":2,"h":5,"i":"13"},
  85. {"x":4,"y":8,"w":2,"h":4,"i":"14"},
  86. {"x":6,"y":8,"w":2,"h":4,"i":"15"},
  87. {"x":8,"y":10,"w":2,"h":5,"i":"16"},
  88. {"x":10,"y":4,"w":2,"h":2,"i":"17"},
  89. {"x":0,"y":9,"w":2,"h":3,"i":"18"},
  90. {"x":2,"y":6,"w":2,"h":2,"i":"19"}
  91. ],
  92. index: 0
  93. },
  94. });
  95. </script>
  96. </body>
  97. </html>