The CSS Drag and Drop Module automatically configures screen reader and keyboard accessible drag and drop functionality using standard DOM elements.
Module files:
The packaged file for this demo can be downloaded from WhatSock.com under Downloads.
Instructions:
The CSS Drag and Drop Module automatically synchronizes mouse and keyboard activity for drag and drop functionality.
// Object literal declaration to configure drag and drop functionality
config = {
// Specify draggable objects
setDrag: 'CSS Selector',
// Specify the drop zone
setDrop: 'CSS Selector',
// Return the string value for every draggable node matching "setDrag" to use as the drag and drop link text
setName: function(obj){
return obj.STRING;
},
// Set the initial styles for the morphed AccDC Object
cssObj: {
property: 'value'
},
// Run script before the AccDC Object opens
runBefore: function(dc){
// Do something
},
// Run script after the AccDC Object opens
runAfter: function(dc){
// Do something
},
// Configure drag and drop event handlers
on: {
dragStart: function(ev, dd, dc){
// Do something
},
drag: function(ev, dd, dc){
// Do something
},
dropStart: function(ev, dd, dc){
// Do something
},
drop: function(ev, dd, dc){
// Do something
},
dropEnd: function(ev, dd, dc){
// Do something
},
dragEnd: function(ev, dd, dc){
// Do something
}
},
// Restrict draggability within a specific container
confineTo: 'CSS Selector',
// Set the drop animation time length in milliseconds for keyboard users
duration: 2000,
// Optionally set a custom insertion point where drop links will be inserted into the DOM
dropAnchor: 'CSS Selector',
// Set additional styling for the hidden drag and drop links
ddCSS: {
property: 'value'
},
// Optionally set a root node for tunneling
root: document
};
// Morph all specified DOM nodes into draggable AccDC Objects
setDragAndDrop(config);