Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>[UPDATE]: YUI is no longer in development, you should instead check <a href="https://shopify.github.io/draggable/" rel="nofollow noreferrer">https://shopify.github.io/draggable/</a> or <a href="https://rubaxa.github.io/Sortable/" rel="nofollow noreferrer">https://rubaxa.github.io/Sortable/</a> or <a href="http://touchpunch.furf.com/" rel="nofollow noreferrer">http://touchpunch.furf.com/</a></p> <p>YUI 3 drag and drop module is fully prepared to work with touch interfaces transparently, you don't have to write any specific code.</p> <p>I've tried it on Ipad and Android phone (also IE, Firefox, Chrome on Windows).</p> <p>You can try the example from here:</p> <blockquote> <p><a href="http://yuilibrary.com/yui/docs/dd/list-drag.html" rel="nofollow noreferrer">http://yuilibrary.com/yui/docs/dd/list-drag.html</a></p> </blockquote> <p>...as well as the rest of examples referenced in that page.</p> <p>I'm using it right now on a project, if you make more specific questions I may be able to give further help.</p> <p>-</p> <p>You can check my slides with links for a comparison of different JS frameworks, and more YUI examples about this matter here: <a href="https://docs.google.com/presentation/d/1YPPomooNx3dP6Vv4JEEXqPmDuA1In3qp9Jz_R7FnRs4/edit" rel="nofollow noreferrer">https://docs.google.com/presentation/d/1YPPomooNx3dP6Vv4JEEXqPmDuA1In3qp9Jz_R7FnRs4/edit</a></p> <p>And you can test YUI drag and drop in JSFiddle here: <a href="http://jsfiddle.net/mordraug/eKe3q/5/" rel="nofollow noreferrer">http://jsfiddle.net/mordraug/eKe3q/5/</a></p> <p><strong>HTML</strong></p> <pre><code>&lt;div id="play"&gt; &lt;ul id="list1"&gt; &lt;li class="list1"&gt;Item #1&lt;/li&gt; &lt;li class="list1"&gt;Item #2&lt;/li&gt; &lt;li class="list1"&gt;Item #3&lt;/li&gt; &lt;li class="list1"&gt;Item #4&lt;/li&gt; &lt;li class="list1"&gt;Item #5&lt;/li&gt; &lt;/ul&gt; &lt;ul id="list2"&gt; &lt;li class="list2"&gt;Item #1&lt;/li&gt; &lt;li class="list2"&gt;Item #2&lt;/li&gt; &lt;li class="list2"&gt;Item #3&lt;/li&gt; &lt;li class="list2"&gt;Item #4&lt;/li&gt; &lt;li class="list2"&gt;Item #5&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p><strong>CSS</strong></p> <pre><code>#play ul li { background-image: none; list-style-type: none; padding-left: 20px; padding: 5px; margin: 2px; cursor: move; zoom: 1; position: relative; } #play ul { border: 1px solid black; margin: 10px; width: 200px; height: 300px; float: left; padding: 0; zoom: 1; position: relative; } #play ul li.list1 { background-color: #8DD5E7; border: 1px solid #004C6D; } #play ul li.list2 { background-color: #EDFF9F; border: 1px solid #CDCDCD; } </code></pre> <p><strong>JavaScript</strong></p> <pre><code>YUI().use('dd-constrain', 'dd-proxy', 'dd-drop', function (Y) { //Listen for all drop:over events Y.DD.DDM.on('drop:over', function (e) { //Get a reference to our drag and drop nodes var drag = e.drag.get('node'), drop = e.drop.get('node'); //Are we dropping on a li node? if (drop.get('tagName').toLowerCase() === 'li') { //Are we not going up? if (!goingUp) { drop = drop.get('nextSibling'); } //Add the node to this list e.drop.get('node').get('parentNode').insertBefore(drag, drop); //Resize this nodes shim, so we can drop on it later. e.drop.sizeShim(); } }); //Listen for all drag:drag events Y.DD.DDM.on('drag:drag', function (e) { //Get the last y point var y = e.target.lastXY[1]; //is it greater than the lastY var? if (y &lt; lastY) { //We are going up goingUp = true; } else { //We are going down. goingUp = false; } //Cache for next check lastY = y; }); //Listen for all drag:start events Y.DD.DDM.on('drag:start', function (e) { //Get our drag object var drag = e.target; //Set some styles here drag.get('node').setStyle('opacity', '.25'); drag.get('dragNode').set('innerHTML', drag.get('node').get('innerHTML')); drag.get('dragNode').setStyles({ opacity: '.5', borderColor: drag.get('node').getStyle('borderColor'), backgroundColor: drag.get('node').getStyle('backgroundColor') }); }); //Listen for a drag:end events Y.DD.DDM.on('drag:end', function (e) { var drag = e.target; //Put our styles back drag.get('node').setStyles({ visibility: '', opacity: '1' }); }); //Listen for all drag:drophit events Y.DD.DDM.on('drag:drophit', function (e) { var drop = e.drop.get('node'), drag = e.drag.get('node'); //if we are not on an li, we must have been dropped on a ul if (drop.get('tagName').toLowerCase() !== 'li') { if (!drop.contains(drag)) { drop.appendChild(drag); } } }); //Static Vars var goingUp = false, lastY = 0; //Get the list of li's in the lists and make them draggable var lis = Y.Node.all('#play ul li'); lis.each(function (v, k) { var dd = new Y.DD.Drag({ node: v, target: { padding: '0 0 0 20' } }).plug(Y.Plugin.DDProxy, { moveOnEnd: false }).plug(Y.Plugin.DDConstrained, { constrain2node: '#play' }); }); //Create simple targets for the 2 lists. var uls = Y.Node.all('#play ul'); uls.each(function (v, k) { var tar = new Y.DD.Drop({ node: v }); }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload