/
dd_and_animation.html
106 lines (82 loc) · 2.46 KB
/
dd_and_animation.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
<?xml version="1.0" encoding="UTF-8"?>
<html>
<head>
<title>WireIt Example, Move and Animate elements containing terminals</title>
<!-- Libs -->
<link rel="stylesheet" href="http://yui.yahooapis.com/combo?3.5.1/build/cssreset/reset-min.css&3.5.1/build/cssfonts/fonts-min.css">
<script src="http://yui.yahooapis.com/3.5.1/build/yui/yui.js"></script>
<script type="text/javascript" src="../lib/excanvas.js"></script>
<!-- WireIt -->
<link rel="stylesheet" type="text/css" href="../assets/WireIt.css" />
<script src="../src/loader.js" type='text/javascript'></script>
<style>
div.blockBox {
/* WireIt */
position: relative;
z-index: 5;
opacity: 0.8;
/* Others */
width: 100px;
height: 100px;
background-color: rgb(255,200,200);
cursor: move;
}
</style>
<script>
YUI_config.groups.wireit.base = '../src/';
YUI({filter: 'raw', combine: false}).use('anim', 'bezier-wire', 'terminal', function(Y) {
// Create 2 terminals into Block1
var block1 = Y.one('#block1');
var terminals1 = [
new Y.Terminal({direction: [-1,0], offsetPosition: [-14,35], render: '#block1'}),
new Y.Terminal({direction: [1,0], offsetPosition: [85,35], render: '#block1'})
];
// Make the block1 draggable
var drag = new Y.DD.Drag({
node: block1
});
var that = this;
drag.on('drag:drag', function(ev) {
Y.Array.each(terminals1, function(t) {
t.redrawAllWires();
});
});
// Create 2 terminals into Block2
var block2 = Y.one('#block2');
var terminals2 = [
new Y.Terminal({direction: [-1,0], offsetPosition: [-14,35], render: '#block2'}),
new Y.Terminal({direction: [1,0], offsetPosition: [85,35], render: '#block2'})
];
// Make the block2 draggable
var drag = new Y.DD.Drag({
node: block2
});
var that = this;
drag.on('drag:drag', function(ev) {
Y.Array.each(terminals2, function(t) {
t.redrawAllWires();
});
});
// Create a wire between some terminals
var w1 = new Y.BezierWire({
render: document.body,
src: terminals1[0],
tgt: terminals2[0]
});
//w1.redraw();
var w2 = new Y.BezierWire({
render: document.body,
src: terminals1[1],
tgt: terminals2[1]
});
//w2.redraw();
});
</script>
</head>
<body>
<p style="margin: 15px;"><a href="../index.html">< Back</a></p>
<p style="margin: 15px;">Show how to make terminal containers draggable</p>
<div id='block1' class="blockBox" style="left: 300px; top: 100px;">Move Me !</div>
<div id='block2' class="blockBox" style="left: 500px; top: 200px;">Move Me !</div>
</body>
</html>