10-drag-from-outside.html 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Vue Grid Layout Example 10 - Drag From Outside</title>
  6. <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
  7. <link rel="stylesheet" href="app.css">
  8. <style>
  9. .droppable-element {
  10. width: 150px;
  11. text-align: center;
  12. background: #fdd;
  13. border: 1px solid black;
  14. margin: 10px 0;
  15. padding: 10px;
  16. }
  17. </style>
  18. </head>
  19. <body @dragover="dragover">
  20. <h1>Vue Grid Layout Example 09 - Drag From Outside</h1>
  21. <a href="https://github.com/jbaysolutions/vue-grid-layout">View project on Github</a>
  22. <br/>
  23. <a href="09-dynamic-add-remove.html">Previous example: Dynamic Add/Remove</a>
  24. <br/>
  25. <!--<a href="">Next example: </a>-->
  26. <br/>
  27. This demo shows what happens when an item is added from outside of the grid.
  28. <br/>
  29. <br/>
  30. Once you drop the item within the grid you'll get its coordinates/properties and can perform actions with it accordingly.
  31. <br/>
  32. <br/>
  33. <div id="app" style="width: 100%;">
  34. <!--<pre>{{ $data | json }}</pre>-->
  35. <div>
  36. <div class="layoutJSON">
  37. Displayed as <code>[x, y, w, h]</code>:
  38. <div class="columns">
  39. <div class="layoutItem" v-for="item in layout">
  40. <b>{{item.i}}</b>: [{{item.x}}, {{item.y}}, {{item.w}}, {{item.h}}]
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. <br/>
  46. <div @drag="drag" @dragend="dragend" class="droppable-element" draggable="true" unselectable="on">Droppable Element (Drag me!)</div>
  47. <div id="content">
  48. <grid-layout ref="gridLayout" :layout.sync="layout"
  49. :col-num="12"
  50. :row-height="30"
  51. :is-draggable="true"
  52. :is-resizable="true"
  53. :vertical-compact="true"
  54. :use-css-transforms="true"
  55. >
  56. <grid-item :key="item.i" v-for="item in layout"
  57. :x="item.x"
  58. :y="item.y"
  59. :w="item.w"
  60. :h="item.h"
  61. :i="item.i"
  62. >
  63. <span class="text">{{item.i}}</span>
  64. </grid-item>
  65. </grid-layout>
  66. </div>
  67. </div>
  68. <script src="vue.min.js"></script>
  69. <script src="../dist/vue-grid-layout.umd.min.js"></script>
  70. <script src="10-drag-from-outside.js"></script>
  71. </body>
  72. </html>