|
525
|
1 |
<!DOCTYPE html> |
|
|
2 |
<html lang="en"> |
|
|
3 |
<head> |
|
|
4 |
<meta charset="utf-8"> |
|
|
5 |
<title>Example: Using the Drag Shim</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: Using the Drag Shim</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 the use of the drag shim when dragging nodes over other troublesome nodes.</p> |
|
|
32 |
</div> |
|
|
33 |
|
|
|
34 |
<div class="example"> |
|
|
35 |
<style> |
|
|
36 |
#demo { |
|
|
37 |
height: 100px; |
|
|
38 |
width: 100px; |
|
|
39 |
border: 1px solid black; |
|
|
40 |
cursor: move; |
|
|
41 |
float: right; |
|
|
42 |
} |
|
|
43 |
#ifrm { |
|
|
44 |
width: 400px; |
|
|
45 |
height: 300px; |
|
|
46 |
} |
|
|
47 |
</style> |
|
|
48 |
|
|
|
49 |
<p>Try dragging the proxy element over the iframe below, in most browsers this will not happen. Now click the <code>Turn Shim On</code> button and drag again. Now you can drag over the iframe.</p> |
|
|
50 |
|
|
|
51 |
<p>You can see the shim by clicking the <code>Turn Debugging On</code> button while using the shim, the default for this example is that the shim is off.</p> |
|
|
52 |
|
|
|
53 |
<p><button id="shim" value="off">Turn Shim On</button> <button id="debugShim" value="off" disabled>Turn Debugging On</button></p> |
|
|
54 |
|
|
|
55 |
<div id="demo">Drag Me</div> |
|
|
56 |
|
|
|
57 |
<iframe id="ifrm" src="../assets/dd/blank.htm"></iframe> |
|
|
58 |
|
|
|
59 |
<script> |
|
|
60 |
YUI().use('dd-ddm', 'dd-drag', 'dd-proxy', function(Y) { |
|
|
61 |
//Toggling the buttons |
|
|
62 |
Y.one('#shim').on('click', function(e) { |
|
|
63 |
var value = e.target.get('value'); |
|
|
64 |
if (value == 'off' || value == 'Turn Shim On') { |
|
|
65 |
dd.set('useShim', true); |
|
|
66 |
e.target.set('value', 'on'); |
|
|
67 |
e.target.set('innerHTML', 'Turn Shim Off'); |
|
|
68 |
Y.one('#debugShim').set('disabled', false); |
|
|
69 |
} else { |
|
|
70 |
dd.set('useShim', false); |
|
|
71 |
e.target.set('value', 'off'); |
|
|
72 |
e.target.set('innerHTML', 'Turn Shim On'); |
|
|
73 |
Y.one('#debugShim').set('disabled', true); |
|
|
74 |
} |
|
|
75 |
}); |
|
|
76 |
|
|
|
77 |
Y.one('#debugShim').on('click', function(e) { |
|
|
78 |
var value = e.target.get('value'); |
|
|
79 |
if (value == 'off' || value == 'Turn Debugging On') { |
|
|
80 |
Y.DD.DDM._debugShim = true; |
|
|
81 |
e.target.set('value', 'on'); |
|
|
82 |
e.target.set('innerHTML', 'Turn Debugging Off'); |
|
|
83 |
} else { |
|
|
84 |
Y.DD.DDM._debugShim = false; |
|
|
85 |
e.target.set('value', 'off'); |
|
|
86 |
e.target.set('innerHTML', 'Turn Debugging On'); |
|
|
87 |
} |
|
|
88 |
}); |
|
|
89 |
|
|
|
90 |
var dd = new Y.DD.Drag({ |
|
|
91 |
//Selector of the node to make draggable |
|
|
92 |
node: '#demo', |
|
|
93 |
useShim: false |
|
|
94 |
}).plug(Y.Plugin.DDProxy, { |
|
|
95 |
offsetNode: false, |
|
|
96 |
resizeFrame: false |
|
|
97 |
}); |
|
|
98 |
dd.on('drag:start', function() { |
|
|
99 |
this.get('dragNode').setStyles({ |
|
|
100 |
height: '20px', |
|
|
101 |
width: '100px', |
|
|
102 |
backgroundColor: 'blue', |
|
|
103 |
color: '#fff' |
|
|
104 |
}); |
|
|
105 |
this.get('dragNode').set('innerHTML', 'Custom Proxy'); |
|
|
106 |
this.deltaXY = [this.deltaXY[0] - 20, this.deltaXY[1] - 20]; |
|
|
107 |
}); |
|
|
108 |
}); |
|
|
109 |
|
|
|
110 |
|
|
|
111 |
</script> |
|
|
112 |
|
|
|
113 |
</div> |
|
|
114 |
|
|
|
115 |
<h3 id="using-the-shim">Using the shim</h3> |
|
|
116 |
<p>Full source code for this example.</p> |
|
|
117 |
|
|
|
118 |
<pre class="code prettyprint">YUI().use('dd-ddm', 'dd-drag', 'dd-proxy', function(Y) { |
|
|
119 |
//Toggling the buttons |
|
|
120 |
Y.one('#shim').on('click', function(e) { |
|
|
121 |
var value = e.target.get('value'); |
|
|
122 |
if (value == 'off' || value == 'Turn Shim On') { |
|
|
123 |
dd.set('useShim', true); |
|
|
124 |
e.target.set('value', 'on'); |
|
|
125 |
e.target.set('innerHTML', 'Turn Shim Off'); |
|
|
126 |
Y.one('#debugShim').set('disabled', false); |
|
|
127 |
} else { |
|
|
128 |
dd.set('useShim', false); |
|
|
129 |
e.target.set('value', 'off'); |
|
|
130 |
e.target.set('innerHTML', 'Turn Shim On'); |
|
|
131 |
Y.one('#debugShim').set('disabled', true); |
|
|
132 |
} |
|
|
133 |
}); |
|
|
134 |
|
|
|
135 |
Y.one('#debugShim').on('click', function(e) { |
|
|
136 |
var value = e.target.get('value'); |
|
|
137 |
if (value == 'off' || value == 'Turn Debugging On') { |
|
|
138 |
Y.DD.DDM._debugShim = true; |
|
|
139 |
e.target.set('value', 'on'); |
|
|
140 |
e.target.set('innerHTML', 'Turn Debugging Off'); |
|
|
141 |
} else { |
|
|
142 |
Y.DD.DDM._debugShim = false; |
|
|
143 |
e.target.set('value', 'off'); |
|
|
144 |
e.target.set('innerHTML', 'Turn Debugging On'); |
|
|
145 |
} |
|
|
146 |
}); |
|
|
147 |
|
|
|
148 |
var dd = new Y.DD.Drag({ |
|
|
149 |
//Selector of the node to make draggable |
|
|
150 |
node: '#demo', |
|
|
151 |
useShim: false |
|
|
152 |
}).plug(Y.Plugin.DDProxy, { |
|
|
153 |
offsetNode: false, |
|
|
154 |
resizeFrame: false |
|
|
155 |
}); |
|
|
156 |
dd.on('drag:start', function() { |
|
|
157 |
this.get('dragNode').setStyles({ |
|
|
158 |
height: '20px', |
|
|
159 |
width: '100px', |
|
|
160 |
backgroundColor: 'blue', |
|
|
161 |
color: '#fff' |
|
|
162 |
}); |
|
|
163 |
this.get('dragNode').set('innerHTML', 'Custom Proxy'); |
|
|
164 |
this.deltaXY = [this.deltaXY[0] - 20, this.deltaXY[1] - 20]; |
|
|
165 |
}); |
|
|
166 |
});</pre> |
|
|
167 |
|
|
|
168 |
</div> |
|
|
169 |
</div> |
|
|
170 |
</div> |
|
|
171 |
|
|
|
172 |
<div class="yui3-u-1-4"> |
|
|
173 |
<div class="sidebar"> |
|
|
174 |
|
|
|
175 |
<div id="toc" class="sidebox"> |
|
|
176 |
<div class="hd"> |
|
|
177 |
<h2 class="no-toc">Table of Contents</h2> |
|
|
178 |
</div> |
|
|
179 |
|
|
|
180 |
<div class="bd"> |
|
|
181 |
<ul class="toc"> |
|
|
182 |
<li> |
|
|
183 |
<a href="#using-the-shim">Using the shim</a> |
|
|
184 |
</li> |
|
|
185 |
</ul> |
|
|
186 |
</div> |
|
|
187 |
</div> |
|
|
188 |
|
|
|
189 |
|
|
|
190 |
|
|
|
191 |
<div class="sidebox"> |
|
|
192 |
<div class="hd"> |
|
|
193 |
<h2 class="no-toc">Examples</h2> |
|
|
194 |
</div> |
|
|
195 |
|
|
|
196 |
<div class="bd"> |
|
|
197 |
<ul class="examples"> |
|
|
198 |
|
|
|
199 |
|
|
|
200 |
<li data-description="A simple drag interaction that doesn't require a drop interaction."> |
|
|
201 |
<a href="simple-drag.html">Simple Drag</a> |
|
|
202 |
</li> |
|
|
203 |
|
|
|
204 |
|
|
|
205 |
|
|
|
206 |
<li data-description="How to apply the Drag Plugin to a node."> |
|
|
207 |
<a href="drag-plugin.html">Drag - Node plugin</a> |
|
|
208 |
</li> |
|
|
209 |
|
|
|
210 |
|
|
|
211 |
|
|
|
212 |
<li data-description="A simple proxy drag interaction that doesn't require a drop interaction."> |
|
|
213 |
<a href="proxy-drag.html">Drag - Proxy</a> |
|
|
214 |
</li> |
|
|
215 |
|
|
|
216 |
|
|
|
217 |
|
|
|
218 |
<li data-description="How to constrain a draggable Node to another Node's region."> |
|
|
219 |
<a href="constrained-drag.html">Drag - Constrained to a Region</a> |
|
|
220 |
</li> |
|
|
221 |
|
|
|
222 |
|
|
|
223 |
|
|
|
224 |
<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."> |
|
|
225 |
<a href="groups-drag.html">Drag - Interaction Groups</a> |
|
|
226 |
</li> |
|
|
227 |
|
|
|
228 |
|
|
|
229 |
|
|
|
230 |
<li data-description="The use of the drag shim when dragging nodes over other troublesome nodes."> |
|
|
231 |
<a href="shim-drag.html">Using the Drag Shim</a> |
|
|
232 |
</li> |
|
|
233 |
|
|
|
234 |
|
|
|
235 |
|
|
|
236 |
<li data-description="How to use the Drop Target events to code your application."> |
|
|
237 |
<a href="drop-code.html">Using Drop Based Coding</a> |
|
|
238 |
</li> |
|
|
239 |
|
|
|
240 |
|
|
|
241 |
|
|
|
242 |
<li data-description="How you can use the DD Scroll plugin to scroll the browser window as you drag."> |
|
|
243 |
<a href="winscroll.html">Window Scrolling</a> |
|
|
244 |
</li> |
|
|
245 |
|
|
|
246 |
|
|
|
247 |
|
|
|
248 |
<li data-description="How to use DD.Delegate to create a scalable solution which supports multiple draggable items."> |
|
|
249 |
<a href="delegate.html">Drag Delegation</a> |
|
|
250 |
</li> |
|
|
251 |
|
|
|
252 |
|
|
|
253 |
|
|
|
254 |
<li data-description="Using DD.Delegate to support dragging multiple items and dropping them onto a Drop Target."> |
|
|
255 |
<a href="delegate-drop.html">Drag Delegation with a Drop Target</a> |
|
|
256 |
</li> |
|
|
257 |
|
|
|
258 |
|
|
|
259 |
|
|
|
260 |
<li data-description="How to use Drag plugins with a DD Delegate based solution."> |
|
|
261 |
<a href="delegate-plugins.html">Using Drag Plugins with Delegate</a> |
|
|
262 |
</li> |
|
|
263 |
|
|
|
264 |
|
|
|
265 |
|
|
|
266 |
<li data-description="This example shows how to make a sortable list using Custom Event Bubbling."> |
|
|
267 |
<a href="list-drag.html">List Reorder w/Bubbling</a> |
|
|
268 |
</li> |
|
|
269 |
|
|
|
270 |
|
|
|
271 |
|
|
|
272 |
<li data-description="This example shows how to make a sortable list using Custom Event Bubbling and Node Scrolling."> |
|
|
273 |
<a href="scroll-list.html">List Reorder w/Scrolling</a> |
|
|
274 |
</li> |
|
|
275 |
|
|
|
276 |
|
|
|
277 |
|
|
|
278 |
<li data-description="How to make an animated node a Drop target."> |
|
|
279 |
<a href="anim-drop.html">Animated Drop Targets</a> |
|
|
280 |
</li> |
|
|
281 |
|
|
|
282 |
|
|
|
283 |
|
|
|
284 |
<li data-description="Example Photo Browser application."> |
|
|
285 |
<a href="photo-browser.html">Photo Browser</a> |
|
|
286 |
</li> |
|
|
287 |
|
|
|
288 |
|
|
|
289 |
|
|
|
290 |
<li data-description="Portal style example using Drag & Drop Event Bubbling and Animation."> |
|
|
291 |
<a href="portal-drag.html">Portal Style Example</a> |
|
|
292 |
</li> |
|
|
293 |
|
|
|
294 |
|
|
|
295 |
|
|
|
296 |
|
|
|
297 |
|
|
|
298 |
|
|
|
299 |
</ul> |
|
|
300 |
</div> |
|
|
301 |
</div> |
|
|
302 |
|
|
|
303 |
|
|
|
304 |
|
|
|
305 |
<div class="sidebox"> |
|
|
306 |
<div class="hd"> |
|
|
307 |
<h2 class="no-toc">Examples That Use This Component</h2> |
|
|
308 |
</div> |
|
|
309 |
|
|
|
310 |
<div class="bd"> |
|
|
311 |
<ul class="examples"> |
|
|
312 |
|
|
|
313 |
|
|
|
314 |
|
|
|
315 |
|
|
|
316 |
|
|
|
317 |
|
|
|
318 |
|
|
|
319 |
|
|
|
320 |
|
|
|
321 |
|
|
|
322 |
|
|
|
323 |
|
|
|
324 |
|
|
|
325 |
|
|
|
326 |
|
|
|
327 |
|
|
|
328 |
|
|
|
329 |
|
|
|
330 |
|
|
|
331 |
|
|
|
332 |
|
|
|
333 |
|
|
|
334 |
|
|
|
335 |
|
|
|
336 |
|
|
|
337 |
|
|
|
338 |
|
|
|
339 |
|
|
|
340 |
|
|
|
341 |
|
|
|
342 |
|
|
|
343 |
|
|
|
344 |
|
|
|
345 |
|
|
|
346 |
<li data-description="Working with multiple YUI instances."> |
|
|
347 |
<a href="../yui/yui-multi.html">Multiple Instances</a> |
|
|
348 |
</li> |
|
|
349 |
|
|
|
350 |
|
|
|
351 |
|
|
|
352 |
<li data-description="Use StyleSheet to adjust the CSS rules applying a page theme from user input"> |
|
|
353 |
<a href="../stylesheet/stylesheet-theme.html">Adjusting a Page Theme on the Fly</a> |
|
|
354 |
</li> |
|
|
355 |
|
|
|
356 |
|
|
|
357 |
</ul> |
|
|
358 |
</div> |
|
|
359 |
</div> |
|
|
360 |
|
|
|
361 |
</div> |
|
|
362 |
</div> |
|
|
363 |
</div> |
|
|
364 |
</div> |
|
|
365 |
|
|
|
366 |
<script src="../assets/vendor/prettify/prettify-min.js"></script> |
|
|
367 |
<script>prettyPrint();</script> |
|
|
368 |
|
|
|
369 |
<script> |
|
|
370 |
YUI.Env.Tests = { |
|
|
371 |
examples: [], |
|
|
372 |
project: '../assets', |
|
|
373 |
assets: '../assets/dd', |
|
|
374 |
name: 'shim-drag', |
|
|
375 |
title: 'Using the Drag Shim', |
|
|
376 |
newWindow: '', |
|
|
377 |
auto: false |
|
|
378 |
}; |
|
|
379 |
YUI.Env.Tests.examples.push('simple-drag'); |
|
|
380 |
YUI.Env.Tests.examples.push('drag-plugin'); |
|
|
381 |
YUI.Env.Tests.examples.push('proxy-drag'); |
|
|
382 |
YUI.Env.Tests.examples.push('constrained-drag'); |
|
|
383 |
YUI.Env.Tests.examples.push('groups-drag'); |
|
|
384 |
YUI.Env.Tests.examples.push('shim-drag'); |
|
|
385 |
YUI.Env.Tests.examples.push('drop-code'); |
|
|
386 |
YUI.Env.Tests.examples.push('winscroll'); |
|
|
387 |
YUI.Env.Tests.examples.push('delegate'); |
|
|
388 |
YUI.Env.Tests.examples.push('delegate-drop'); |
|
|
389 |
YUI.Env.Tests.examples.push('delegate-plugins'); |
|
|
390 |
YUI.Env.Tests.examples.push('list-drag'); |
|
|
391 |
YUI.Env.Tests.examples.push('scroll-list'); |
|
|
392 |
YUI.Env.Tests.examples.push('anim-drop'); |
|
|
393 |
YUI.Env.Tests.examples.push('photo-browser'); |
|
|
394 |
YUI.Env.Tests.examples.push('portal-drag'); |
|
|
395 |
YUI.Env.Tests.examples.push('yui-multi'); |
|
|
396 |
YUI.Env.Tests.examples.push('stylesheet-theme'); |
|
|
397 |
|
|
|
398 |
</script> |
|
|
399 |
<script src="../assets/yui/test-runner.js"></script> |
|
|
400 |
|
|
|
401 |
|
|
|
402 |
|
|
|
403 |
</body> |
|
|
404 |
</html> |