<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Vue Grid Layout Example 10 - Drag From Outside</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="app.css">

	<style>
	.droppable-element {
        width: 150px;
        text-align: center;
        background: #fdd;
        border: 1px solid black;
        margin: 10px 0;
        padding: 10px;
    }
    </style>

</head>
<body @dragover="dragover">
    <h1>Vue Grid Layout Example 09 - Drag From Outside</h1>

    <a href="https://github.com/jbaysolutions/vue-grid-layout">View project on Github</a>
    <br/>
    <a href="09-dynamic-add-remove.html">Previous example: Dynamic Add/Remove</a>
    <br/>
    <a href="11-bounded.html">Next example: Bounded</a>

    <br/>
    This demo shows what happens when an item is added from outside of the grid.
    <br/>
    <br/>
    Once you drop the item within the grid you'll get its coordinates/properties and can perform actions with it accordingly.
    <br/>
    <br/>

    <div id="app" style="width: 100%;">
        <!--<pre>{{ $data | json }}</pre>-->
        <div>
            <div class="layoutJSON">
                Displayed as <code>[x, y, w, h]</code>:
                <div class="columns">
                    <div class="layoutItem" v-for="item in layout">
                        <b>{{item.i}}</b>: [{{item.x}}, {{item.y}}, {{item.w}}, {{item.h}}]
                    </div>
                </div>
            </div>
        </div>
        <br/>
        <div @drag="drag" @dragend="dragend" class="droppable-element" draggable="true" unselectable="on">Droppable Element (Drag me!)</div>
        <div id="content">
            <grid-layout  ref="gridLayout" :layout.sync="layout"
                         :col-num="12"
                         :row-height="30"
                         :is-draggable="true"
                         :is-resizable="true"
                         :vertical-compact="true"
                         :use-css-transforms="true"

            >
                <grid-item :key="item.i" v-for="item in layout"
                           :x="item.x"
                           :y="item.y"
                           :w="item.w"
                           :h="item.h"
                           :i="item.i"
                >
                    <span class="text">{{item.i}}</span>
                </grid-item>
            </grid-layout>
        </div>
    </div>
    <script src="vue.min.js"></script>
    <script src="../dist/vue-grid-layout.umd.min.js"></script>
    <script src="10-drag-from-outside.js"></script>
</body>
</html>
