-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
119 lines (102 loc) · 3.05 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE html>
<html>
<head>
<title>juicy-draggable</title>
<meta charset="utf-8" />
<script src="../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../polymer/polymer.html" />
<link rel="import" href="juicy-draggable.html" />
<style>
#drag {
overflow: visible;
padding-left: 420px;
min-height: 60px;
}
.drag,
.drag-helper {
width: 200px;
line-height: 50px;
float: left;
margin: 0px 10px 10px 0px;
border: 1px dashed #333333;
text-align: center;
cursor: move;
}
#drop {
clear: both;
border: 1px solid #333333;
padding: 0px;
}
#drop p {
border-bottom: 1px solid #333333;
padding: 10px;
margin: 0px;
}
#drop div.drop {
min-height: 100px;
padding: 10px;
}
#drop .drag {
cursor: default;
}
.drag-helper {
display: none;
}
.drag-helper.dragging {
display: block;
}
.drag-hover {
background-color: #eeffc5;
}
juicy-draggable.fixed .drag {
left: 10px;
}
juicy-draggable.fixed-drop .drag {
left: 220px;
}
</style>
</head>
<body>
<h3>juicy-draggable</h3>
<p>This demo requires Polymer</p>
<dom-bind id="root">
<template>
<div id="drag">
<juicy-draggable position="static" dropselector="#drop div.drop" on-juicy-draggable-stop="itemDropped">
<div class="drag">Drag and drop my copy</div>
</juicy-draggable>
<juicy-draggable class="fixed-drop" dropselector="#drop div.drop" on-juicy-draggable-stop="itemDropped">
<div class="drag">Drag and drop me</div>
</juicy-draggable>
<juicy-draggable class="fixed">
<div class="drag">Drag me around</div>
</juicy-draggable>
</div>
<div id="drop">
<p>Drop zone</p>
<div class="drop"></div>
</div>
</template>
</dom-bind>
<script>
var template = document.querySelector("#root");
template.itemDropped = function (event) {
if (!event.detail.dropElement) {
return;
}
var target = event.currentTarget;
var drag = event.detail.dragElement;
var drop = event.detail.dropElement;
if (target.position == "static") {
var origin = drag.nextElementSibling;
drop.appendChild(origin);
drag.parentNode.removeChild(drag);
} else {
drop.appendChild(drag);
drag.style.position = "";
target.setAttribute("disabled", "disabled");
}
};
</script>
</body>
</html>