5
<title>Example: Using the Drag Shim</title>
6
<link rel="stylesheet" href="http://yui.yahooapis.com/3.4.0pr3/build/cssgrids/grids-min.css">
7
<link rel="stylesheet" href="../assets/css/main.css">
8
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
9
<script src="../../build/yui/yui-min.js"></script>
14
<h1>Example: Using the Drag Shim</h1>
17
<a href="#toc" class="jump">Jump to Table of Contents</a>
21
<div id="main" class="yui3-u">
22
<div class="content"><div class="intro">
23
<p>This example shows the use of the drag shim when dragging nodes over other troublesome nodes.</p>
31
border: 1px solid black;
41
<p>Try dragging the proxy element over the iframe below, in most browsers this will not happen. Now click the <code>Shim off</code> button and drag again. Now you can drag over the iframe.</p>
43
<p>You can see the shim by clicking the <code>Debug Off</code> button.</p>
45
<p><button id="shim" value="off">Shim Off</button> <button id="debugShim" value="off" disabled>Debug Off</button></p>
47
<div id="demo">Drag Me</div>
49
<iframe id="ifrm" src="../assets/dd/blank.htm"></iframe>
52
YUI().use('dd-ddm', 'dd-drag', 'dd-proxy', function(Y) {
53
//Toggling the buttons
54
Y.one('#shim').on('click', function(e) {
55
var value = e.target.get('value');
56
if (value == 'off' || value == 'Shim Off') {
57
dd.set('useShim', true);
58
e.target.set('value', 'on');
59
e.target.set('innerHTML', 'Shim On');
60
Y.one('#debugShim').set('disabled', false);
62
dd.set('useShim', false);
63
e.target.set('value', 'off');
64
e.target.set('innerHTML', 'Shim Off');
65
Y.one('#debugShim').set('disabled', true);
69
Y.one('#debugShim').on('click', function(e) {
70
var value = e.target.get('value');
71
if (value == 'off' || value == 'Debug Off') {
72
Y.DD.DDM._debugShim = true;
73
e.target.set('value', 'on');
74
e.target.set('innerHTML', 'Debug On');
76
Y.DD.DDM._debugShim = false;
77
e.target.set('value', 'off');
78
e.target.set('innerHTML', 'Debug Off');
82
var dd = new Y.DD.Drag({
83
//Selector of the node to make draggable
86
}).plug(Y.Plugin.DDProxy, {
90
dd.on('drag:start', function() {
91
this.get('dragNode').setStyles({
94
backgroundColor: 'blue',
97
this.get('dragNode').set('innerHTML', 'Custom Proxy');
98
this.deltaXY = [this.deltaXY[0] - 20, this.deltaXY[1] - 20];
107
<h3 id="using-the-shim">Using the shim</h3>
108
<p>Full source code for this example.</p>
110
<pre class="code prettyprint">YUI().use('dd-ddm', 'dd-drag', 'dd-proxy', function(Y) {
111
//Toggling the buttons
112
Y.one('#shim').on('click', function(e) {
113
var value = e.target.get('value');
114
if (value == 'off' || value == 'Shim Off') {
115
dd.set('useShim', true);
116
e.target.set('value', 'on');
117
e.target.set('innerHTML', 'Shim On');
118
Y.one('#debugShim').set('disabled', false);
120
dd.set('useShim', false);
121
e.target.set('value', 'off');
122
e.target.set('innerHTML', 'Shim Off');
123
Y.one('#debugShim').set('disabled', true);
127
Y.one('#debugShim').on('click', function(e) {
128
var value = e.target.get('value');
129
if (value == 'off' || value == 'Debug Off') {
130
Y.DD.DDM._debugShim = true;
131
e.target.set('value', 'on');
132
e.target.set('innerHTML', 'Debug On');
134
Y.DD.DDM._debugShim = false;
135
e.target.set('value', 'off');
136
e.target.set('innerHTML', 'Debug Off');
140
var dd = new Y.DD.Drag({
141
//Selector of the node to make draggable
142
node: '#demo',
144
}).plug(Y.Plugin.DDProxy, {
148
dd.on('drag:start', function() {
149
this.get('dragNode').setStyles({
150
height: '20px',
151
width: '100px',
152
backgroundColor: 'blue',
153
color: '#fff'
155
this.get('dragNode').set('innerHTML', 'Custom Proxy');
156
this.deltaXY = [this.deltaXY[0] - 20, this.deltaXY[1] - 20];
163
<div id="sidebar" class="yui3-u">
165
<div id="toc" class="sidebox">
167
<h2 class="no-toc">Table of Contents</h2>
173
<a href="#using-the-shim">Using the shim</a>
181
<div class="sidebox">
183
<h2 class="no-toc">Examples</h2>
187
<ul class="examples">
190
<li data-description="A simple drag interaction that doesn't require a drop interaction.">
191
<a href="simple-drag.html">Simple Drag</a>
196
<li data-description="How to apply the Drag Plugin to a node.">
197
<a href="drag-plugin.html">Drag - Node plugin</a>
202
<li data-description="A simple proxy drag interaction that doesn't require a drop interaction.">
203
<a href="proxy-drag.html">Drag - Proxy</a>
208
<li data-description="How to constrain a draggable Node to another Node's region.">
209
<a href="constrained-drag.html">Drag - Constrained to a Region</a>
214
<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.">
215
<a href="groups-drag.html">Drag - Interaction Groups</a>
220
<li data-description="The use of the drag shim when dragging nodes over other troublesome nodes.">
221
<a href="shim-drag.html">Using the Drag Shim</a>
226
<li data-description="How to use the Drop Target events to code your application.">
227
<a href="drop-code.html">Using Drop Based Coding</a>
232
<li data-description="How you can use the DD Scroll plugin to scroll the browser window as you drag.">
233
<a href="winscroll.html">Window Scrolling</a>
238
<li data-description="How to use DD.Delegate to create a scalable solution which supports multiple draggable items.">
239
<a href="delegate.html">Drag Delegation</a>
244
<li data-description="Using DD.Delegate to support dragging multiple items and dropping them onto a Drop Target.">
245
<a href="delegate-drop.html">Drag Delegation with a Drop Target</a>
250
<li data-description="How to use Drag plugins with a DD Delegate based solution.">
251
<a href="delegate-plugins.html">Using Drag Plugins with Delegate</a>
256
<li data-description="This example shows how to make a sortable list using Custom Event Bubbling.">
257
<a href="list-drag.html">List Reorder w/Bubbling</a>
262
<li data-description="This example shows how to make a sortable list using Custom Event Bubbling and Node Scrolling.">
263
<a href="scroll-list.html">List Reorder w/Scrolling</a>
268
<li data-description="How to make an animated node a Drop target.">
269
<a href="anim-drop.html">Animated Drop Targets</a>
274
<li data-description="Example Photo Browser application.">
275
<a href="photo-browser.html">Photo Browser</a>
280
<li data-description="Portal style example using Drag & Drop Event Bubbling and Animation.">
281
<a href="portal-drag.html">Portal Style Example</a>
295
<div class="sidebox">
297
<h2 class="no-toc">Examples That Use This Component</h2>
301
<ul class="examples">
336
<li data-description="Working with multiple YUI instances.">
337
<a href="../yui/yui-multi.html">Multiple Instances</a>
342
<li data-description="Use StyleSheet to adjust the CSS rules applying a page theme from user input">
343
<a href="../stylesheet/stylesheet-theme.html">Adjusting a Page Theme on the Fly</a>
355
<script src="../assets/vendor/prettify/prettify-min.js"></script>
356
<script>prettyPrint();</script>