|
525
|
1 |
<!DOCTYPE html> |
|
|
2 |
<html lang="en"> |
|
|
3 |
<head> |
|
|
4 |
<meta charset="utf-8"> |
|
|
5 |
<title>Example: Drag - Proxy</title> |
|
|
6 |
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans:400,700,400italic,700italic"> |
|
|
7 |
<link rel="stylesheet" href="../../build/cssgrids/cssgrids-min.css"> |
|
|
8 |
<link rel="stylesheet" href="../assets/css/main.css"> |
|
|
9 |
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css"> |
|
|
10 |
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png"> |
|
|
11 |
<script src="../../build/yui/yui-min.js"></script> |
|
|
12 |
|
|
|
13 |
</head> |
|
|
14 |
<body> |
|
|
15 |
<!-- |
|
|
16 |
<a href="https://github.com/yui/yui3"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a> |
|
|
17 |
--> |
|
|
18 |
<div id="doc"> |
|
|
19 |
<div id="hd"> |
|
|
20 |
<h1><img src="http://yuilibrary.com/img/yui-logo.png"></h1> |
|
|
21 |
</div> |
|
|
22 |
|
|
|
23 |
<a href="#toc" class="jump">Jump to Table of Contents</a> |
|
|
24 |
|
|
|
25 |
|
|
|
26 |
<h1>Example: Drag - Proxy</h1> |
|
|
27 |
<div class="yui3-g"> |
|
|
28 |
<div class="yui3-u-3-4"> |
|
|
29 |
<div id="main"> |
|
|
30 |
<div class="content"><div class="intro"> |
|
|
31 |
<p>This example shows a simple proxy drag interaction that doesn't require a drop interaction.</p> |
|
|
32 |
</div> |
|
|
33 |
|
|
|
34 |
<div class="example"> |
|
|
35 |
<style> |
|
|
36 |
#demo { |
|
|
37 |
height: 100px; |
|
|
38 |
width: 100px; |
|
|
39 |
border: 1px solid black; |
|
|
40 |
background-color: #8DD5E7; |
|
|
41 |
cursor: move; |
|
|
42 |
} |
|
|
43 |
</style> |
|
|
44 |
|
|
|
45 |
<div id="demo">Drag Me</div> |
|
|
46 |
|
|
|
47 |
<script> |
|
|
48 |
|
|
|
49 |
YUI().use('dd-drag', 'dd-proxy', function(Y) { |
|
|
50 |
var dd = new Y.DD.Drag({ |
|
|
51 |
//Selector of the node to make draggable |
|
|
52 |
node: '#demo' |
|
|
53 |
}).plug(Y.Plugin.DDProxy); //This config option makes the node a Proxy Drag |
|
|
54 |
}); |
|
|
55 |
</script> |
|
|
56 |
|
|
|
57 |
</div> |
|
|
58 |
|
|
|
59 |
<h3 id="setting-up-the-node">Setting up the Node</h3> |
|
|
60 |
<p>First we need to create an HTML Node to make draggable.</p> |
|
|
61 |
|
|
|
62 |
<pre class="code prettyprint"><div id="demo">Drag Me</div></pre> |
|
|
63 |
|
|
|
64 |
|
|
|
65 |
<p>Now we give that Node some CSS to make it visible.</p> |
|
|
66 |
|
|
|
67 |
<pre class="code prettyprint">#demo { |
|
|
68 |
height: 100px; |
|
|
69 |
width: 100px; |
|
|
70 |
border: 1px solid black; |
|
|
71 |
background-color: #8DD5E7; |
|
|
72 |
cursor: move; |
|
|
73 |
}</pre> |
|
|
74 |
|
|
|
75 |
|
|
|
76 |
<h3 id="setting-up-the-yui-instance">Setting up the YUI Instance</h3> |
|
|
77 |
<p>Now we need to create our YUI instance and tell it to load the <code>dd-drag</code> and <code>dd-proxy</code> modules.</p> |
|
|
78 |
|
|
|
79 |
<pre class="code prettyprint">YUI().use('dd-drag', 'dd-proxy');</pre> |
|
|
80 |
|
|
|
81 |
|
|
|
82 |
<h3 id="making-the-node-draggable">Making the Node draggable</h3> |
|
|
83 |
<p>Now that we have a YUI instance with the <code>dd-drag</code> and <code>dd-proxy</code> modules, we need to instantiate the <code>Drag</code> instance on this Node and add the <code>DDProxy</code> plugin.</p> |
|
|
84 |
|
|
|
85 |
<pre class="code prettyprint">YUI().use('dd-drag', 'dd-proxy', function(Y) { |
|
|
86 |
//Selector of the node to make draggable |
|
|
87 |
var dd = new Y.DD.Drag({ |
|
|
88 |
node: '#demo', |
|
|
89 |
}).plug(Y.Plugin.DDProxy); //This config option makes the node a Proxy Drag |
|
|
90 |
});</pre> |
|
|
91 |
|
|
|
92 |
</div> |
|
|
93 |
</div> |
|
|
94 |
</div> |
|
|
95 |
|
|
|
96 |
<div class="yui3-u-1-4"> |
|
|
97 |
<div class="sidebar"> |
|
|
98 |
|
|
|
99 |
<div id="toc" class="sidebox"> |
|
|
100 |
<div class="hd"> |
|
|
101 |
<h2 class="no-toc">Table of Contents</h2> |
|
|
102 |
</div> |
|
|
103 |
|
|
|
104 |
<div class="bd"> |
|
|
105 |
<ul class="toc"> |
|
|
106 |
<li> |
|
|
107 |
<a href="#setting-up-the-node">Setting up the Node</a> |
|
|
108 |
</li> |
|
|
109 |
<li> |
|
|
110 |
<a href="#setting-up-the-yui-instance">Setting up the YUI Instance</a> |
|
|
111 |
</li> |
|
|
112 |
<li> |
|
|
113 |
<a href="#making-the-node-draggable">Making the Node draggable</a> |
|
|
114 |
</li> |
|
|
115 |
</ul> |
|
|
116 |
</div> |
|
|
117 |
</div> |
|
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
|
121 |
<div class="sidebox"> |
|
|
122 |
<div class="hd"> |
|
|
123 |
<h2 class="no-toc">Examples</h2> |
|
|
124 |
</div> |
|
|
125 |
|
|
|
126 |
<div class="bd"> |
|
|
127 |
<ul class="examples"> |
|
|
128 |
|
|
|
129 |
|
|
|
130 |
<li data-description="A simple drag interaction that doesn't require a drop interaction."> |
|
|
131 |
<a href="simple-drag.html">Simple Drag</a> |
|
|
132 |
</li> |
|
|
133 |
|
|
|
134 |
|
|
|
135 |
|
|
|
136 |
<li data-description="How to apply the Drag Plugin to a node."> |
|
|
137 |
<a href="drag-plugin.html">Drag - Node plugin</a> |
|
|
138 |
</li> |
|
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
|
142 |
<li data-description="A simple proxy drag interaction that doesn't require a drop interaction."> |
|
|
143 |
<a href="proxy-drag.html">Drag - Proxy</a> |
|
|
144 |
</li> |
|
|
145 |
|
|
|
146 |
|
|
|
147 |
|
|
|
148 |
<li data-description="How to constrain a draggable Node to another Node's region."> |
|
|
149 |
<a href="constrained-drag.html">Drag - Constrained to a Region</a> |
|
|
150 |
</li> |
|
|
151 |
|
|
|
152 |
|
|
|
153 |
|
|
|
154 |
<li data-description="Using interaction groups, this example demonstrates how to tie into the Drag & Drop Utility's interesting moments to provide visual affordances for the current drag operation."> |
|
|
155 |
<a href="groups-drag.html">Drag - Interaction Groups</a> |
|
|
156 |
</li> |
|
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
<li data-description="The use of the drag shim when dragging nodes over other troublesome nodes."> |
|
|
161 |
<a href="shim-drag.html">Using the Drag Shim</a> |
|
|
162 |
</li> |
|
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
|
166 |
<li data-description="How to use the Drop Target events to code your application."> |
|
|
167 |
<a href="drop-code.html">Using Drop Based Coding</a> |
|
|
168 |
</li> |
|
|
169 |
|
|
|
170 |
|
|
|
171 |
|
|
|
172 |
<li data-description="How you can use the DD Scroll plugin to scroll the browser window as you drag."> |
|
|
173 |
<a href="winscroll.html">Window Scrolling</a> |
|
|
174 |
</li> |
|
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
|
178 |
<li data-description="How to use DD.Delegate to create a scalable solution which supports multiple draggable items."> |
|
|
179 |
<a href="delegate.html">Drag Delegation</a> |
|
|
180 |
</li> |
|
|
181 |
|
|
|
182 |
|
|
|
183 |
|
|
|
184 |
<li data-description="Using DD.Delegate to support dragging multiple items and dropping them onto a Drop Target."> |
|
|
185 |
<a href="delegate-drop.html">Drag Delegation with a Drop Target</a> |
|
|
186 |
</li> |
|
|
187 |
|
|
|
188 |
|
|
|
189 |
|
|
|
190 |
<li data-description="How to use Drag plugins with a DD Delegate based solution."> |
|
|
191 |
<a href="delegate-plugins.html">Using Drag Plugins with Delegate</a> |
|
|
192 |
</li> |
|
|
193 |
|
|
|
194 |
|
|
|
195 |
|
|
|
196 |
<li data-description="This example shows how to make a sortable list using Custom Event Bubbling."> |
|
|
197 |
<a href="list-drag.html">List Reorder w/Bubbling</a> |
|
|
198 |
</li> |
|
|
199 |
|
|
|
200 |
|
|
|
201 |
|
|
|
202 |
<li data-description="This example shows how to make a sortable list using Custom Event Bubbling and Node Scrolling."> |
|
|
203 |
<a href="scroll-list.html">List Reorder w/Scrolling</a> |
|
|
204 |
</li> |
|
|
205 |
|
|
|
206 |
|
|
|
207 |
|
|
|
208 |
<li data-description="How to make an animated node a Drop target."> |
|
|
209 |
<a href="anim-drop.html">Animated Drop Targets</a> |
|
|
210 |
</li> |
|
|
211 |
|
|
|
212 |
|
|
|
213 |
|
|
|
214 |
<li data-description="Example Photo Browser application."> |
|
|
215 |
<a href="photo-browser.html">Photo Browser</a> |
|
|
216 |
</li> |
|
|
217 |
|
|
|
218 |
|
|
|
219 |
|
|
|
220 |
<li data-description="Portal style example using Drag & Drop Event Bubbling and Animation."> |
|
|
221 |
<a href="portal-drag.html">Portal Style Example</a> |
|
|
222 |
</li> |
|
|
223 |
|
|
|
224 |
|
|
|
225 |
|
|
|
226 |
|
|
|
227 |
|
|
|
228 |
|
|
|
229 |
</ul> |
|
|
230 |
</div> |
|
|
231 |
</div> |
|
|
232 |
|
|
|
233 |
|
|
|
234 |
|
|
|
235 |
<div class="sidebox"> |
|
|
236 |
<div class="hd"> |
|
|
237 |
<h2 class="no-toc">Examples That Use This Component</h2> |
|
|
238 |
</div> |
|
|
239 |
|
|
|
240 |
<div class="bd"> |
|
|
241 |
<ul class="examples"> |
|
|
242 |
|
|
|
243 |
|
|
|
244 |
|
|
|
245 |
|
|
|
246 |
|
|
|
247 |
|
|
|
248 |
|
|
|
249 |
|
|
|
250 |
|
|
|
251 |
|
|
|
252 |
|
|
|
253 |
|
|
|
254 |
|
|
|
255 |
|
|
|
256 |
|
|
|
257 |
|
|
|
258 |
|
|
|
259 |
|
|
|
260 |
|
|
|
261 |
|
|
|
262 |
|
|
|
263 |
|
|
|
264 |
|
|
|
265 |
|
|
|
266 |
|
|
|
267 |
|
|
|
268 |
|
|
|
269 |
|
|
|
270 |
|
|
|
271 |
|
|
|
272 |
|
|
|
273 |
|
|
|
274 |
|
|
|
275 |
|
|
|
276 |
<li data-description="Working with multiple YUI instances."> |
|
|
277 |
<a href="../yui/yui-multi.html">Multiple Instances</a> |
|
|
278 |
</li> |
|
|
279 |
|
|
|
280 |
|
|
|
281 |
|
|
|
282 |
<li data-description="Use StyleSheet to adjust the CSS rules applying a page theme from user input"> |
|
|
283 |
<a href="../stylesheet/stylesheet-theme.html">Adjusting a Page Theme on the Fly</a> |
|
|
284 |
</li> |
|
|
285 |
|
|
|
286 |
|
|
|
287 |
</ul> |
|
|
288 |
</div> |
|
|
289 |
</div> |
|
|
290 |
|
|
|
291 |
</div> |
|
|
292 |
</div> |
|
|
293 |
</div> |
|
|
294 |
</div> |
|
|
295 |
|
|
|
296 |
<script src="../assets/vendor/prettify/prettify-min.js"></script> |
|
|
297 |
<script>prettyPrint();</script> |
|
|
298 |
|
|
|
299 |
<script> |
|
|
300 |
YUI.Env.Tests = { |
|
|
301 |
examples: [], |
|
|
302 |
project: '../assets', |
|
|
303 |
assets: '../assets/dd', |
|
|
304 |
name: 'proxy-drag', |
|
|
305 |
title: 'Drag - Proxy', |
|
|
306 |
newWindow: '', |
|
|
307 |
auto: false |
|
|
308 |
}; |
|
|
309 |
YUI.Env.Tests.examples.push('simple-drag'); |
|
|
310 |
YUI.Env.Tests.examples.push('drag-plugin'); |
|
|
311 |
YUI.Env.Tests.examples.push('proxy-drag'); |
|
|
312 |
YUI.Env.Tests.examples.push('constrained-drag'); |
|
|
313 |
YUI.Env.Tests.examples.push('groups-drag'); |
|
|
314 |
YUI.Env.Tests.examples.push('shim-drag'); |
|
|
315 |
YUI.Env.Tests.examples.push('drop-code'); |
|
|
316 |
YUI.Env.Tests.examples.push('winscroll'); |
|
|
317 |
YUI.Env.Tests.examples.push('delegate'); |
|
|
318 |
YUI.Env.Tests.examples.push('delegate-drop'); |
|
|
319 |
YUI.Env.Tests.examples.push('delegate-plugins'); |
|
|
320 |
YUI.Env.Tests.examples.push('list-drag'); |
|
|
321 |
YUI.Env.Tests.examples.push('scroll-list'); |
|
|
322 |
YUI.Env.Tests.examples.push('anim-drop'); |
|
|
323 |
YUI.Env.Tests.examples.push('photo-browser'); |
|
|
324 |
YUI.Env.Tests.examples.push('portal-drag'); |
|
|
325 |
YUI.Env.Tests.examples.push('yui-multi'); |
|
|
326 |
YUI.Env.Tests.examples.push('stylesheet-theme'); |
|
|
327 |
|
|
|
328 |
</script> |
|
|
329 |
<script src="../assets/yui/test-runner.js"></script> |
|
|
330 |
|
|
|
331 |
|
|
|
332 |
|
|
|
333 |
</body> |
|
|
334 |
</html> |