5
<title>Example: Window Scrolling</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: Window Scrolling</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 how you can use the DD Scroll plugin to scroll the browser window as you drag.</p>
31
border: 1px solid black;
32
background-color: #8DD5E7;
51
<div id="demo"><h2 class="no-toc">x</h2>Drag Me</div>
55
YUI().use('dd-drag', 'dd-scroll', 'dd', function(Y) {
56
var dd = new Y.DD.Drag({
58
}).addHandle('h2').plug(Y.Plugin.DDWinScroll);
67
<h3 id="setting-up-the-node">Setting up the Node</h3>
68
<p>First we need to create an HTML Node to make draggable.</p>
70
<pre class="code prettyprint"><div id="demo"><h2 class="no-toc">x</h2>Drag Me</div></pre>
73
<p>Now we give that Node some CSS to make it visible.</p>
75
<pre class="code prettyprint">#demo {
78
border: 1px solid black;
79
background-color: #8DD5E7;
96
<h3 id="setting-up-the-yui-instance">Setting up the YUI Instance</h3>
97
<p>Now we need to create our YUI instance and tell it to load the <code>dd-drag</code> and <code>dd-scroll</code> modules.</p>
99
<pre class="code prettyprint">YUI().use('dd-drag', 'dd-scroll');</pre>
102
<h3 id="making-the-node-draggable-with-dd">Making the Node draggable with DD</h3>
103
<p>Now that we have a YUI instance with the <code>dd-drag</code> and <code>dd-scroll</code> modules, we need to instantiate a <code>DD</code> instance from this Node.</p>
105
<pre class="code prettyprint">var dd = new Y.DD.Drag({
106
node: '#demo'
107
}).addHandle('h2');</pre>
110
<h3 id="making-the-window-scroll">Making the Window Scroll</h3>
111
<p>Now that we have a draggable Node, we need to plug the <code>Plugin.DDWinScroll</code> plugin onto the Drag instance.</p>
113
<pre class="code prettyprint">var dd = new Y.DD.Drag({
114
node: '#demo'
115
}).addHandle('h2').plug(Y.Plugin.DDWinScroll);</pre>
120
<div id="sidebar" class="yui3-u">
122
<div id="toc" class="sidebox">
124
<h2 class="no-toc">Table of Contents</h2>
130
<a href="#setting-up-the-node">Setting up the Node</a>
133
<a href="#setting-up-the-yui-instance">Setting up the YUI Instance</a>
136
<a href="#making-the-node-draggable-with-dd">Making the Node draggable with DD</a>
139
<a href="#making-the-window-scroll">Making the Window Scroll</a>
147
<div class="sidebox">
149
<h2 class="no-toc">Examples</h2>
153
<ul class="examples">
156
<li data-description="A simple drag interaction that doesn't require a drop interaction.">
157
<a href="simple-drag.html">Simple Drag</a>
162
<li data-description="How to apply the Drag Plugin to a node.">
163
<a href="drag-plugin.html">Drag - Node plugin</a>
168
<li data-description="A simple proxy drag interaction that doesn't require a drop interaction.">
169
<a href="proxy-drag.html">Drag - Proxy</a>
174
<li data-description="How to constrain a draggable Node to another Node's region.">
175
<a href="constrained-drag.html">Drag - Constrained to a Region</a>
180
<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.">
181
<a href="groups-drag.html">Drag - Interaction Groups</a>
186
<li data-description="The use of the drag shim when dragging nodes over other troublesome nodes.">
187
<a href="shim-drag.html">Using the Drag Shim</a>
192
<li data-description="How to use the Drop Target events to code your application.">
193
<a href="drop-code.html">Using Drop Based Coding</a>
198
<li data-description="How you can use the DD Scroll plugin to scroll the browser window as you drag.">
199
<a href="winscroll.html">Window Scrolling</a>
204
<li data-description="How to use DD.Delegate to create a scalable solution which supports multiple draggable items.">
205
<a href="delegate.html">Drag Delegation</a>
210
<li data-description="Using DD.Delegate to support dragging multiple items and dropping them onto a Drop Target.">
211
<a href="delegate-drop.html">Drag Delegation with a Drop Target</a>
216
<li data-description="How to use Drag plugins with a DD Delegate based solution.">
217
<a href="delegate-plugins.html">Using Drag Plugins with Delegate</a>
222
<li data-description="This example shows how to make a sortable list using Custom Event Bubbling.">
223
<a href="list-drag.html">List Reorder w/Bubbling</a>
228
<li data-description="This example shows how to make a sortable list using Custom Event Bubbling and Node Scrolling.">
229
<a href="scroll-list.html">List Reorder w/Scrolling</a>
234
<li data-description="How to make an animated node a Drop target.">
235
<a href="anim-drop.html">Animated Drop Targets</a>
240
<li data-description="Example Photo Browser application.">
241
<a href="photo-browser.html">Photo Browser</a>
246
<li data-description="Portal style example using Drag & Drop Event Bubbling and Animation.">
247
<a href="portal-drag.html">Portal Style Example</a>
261
<div class="sidebox">
263
<h2 class="no-toc">Examples That Use This Component</h2>
267
<ul class="examples">
302
<li data-description="Working with multiple YUI instances.">
303
<a href="../yui/yui-multi.html">Multiple Instances</a>
308
<li data-description="Use StyleSheet to adjust the CSS rules applying a page theme from user input">
309
<a href="../stylesheet/stylesheet-theme.html">Adjusting a Page Theme on the Fly</a>
321
<script src="../assets/vendor/prettify/prettify-min.js"></script>
322
<script>prettyPrint();</script>