|
|
|
|
FF1+ IE5+ Opr7+
DOM Drag & Drop scriptDescription: This is a superb DOM drag and drop script that be used on any relatively or absolutely positioned element on the page to make it instantly dragable. What we like most about this script is its very compact, no fuss design. The script also fires 3 custom event handlers that let your page sense and react to the dragging in some fashion. Very nice! Simple example:
Drag me!
Step 1: Add the below code to the <HEAD> section of your page: Step 2: As you can see, this script references an external .js file. Download "DOM-Drag-Drop-script/dom-drag.js" (right click, and select "Save-As"), and upload to your web page directory. And that's it, well the installation part at least. Applying the script to an elementNote: See
also: author's
tutorial page.
Now here comes the fun part, making an element on the page dragable! The basic version To make an element draggable using this script simply call Drag.init(obj), with "obj" being the reference to the element in question. For example: <img id="example" src="lips.gif" style="position: relative" />
<script type="text/javascript">
Drag.init(document.getElementById("example"));
</script>
A couple of important points to mention here:
Creating a draggable handle Sometimes you want to set only a special area within a complex object to be draggable - aka a handle. To do this, pass two references to the method Drag.init(): the handle and the root. <div id="root" style="left:50px; top:50px;">
<div id="handle">Handle</div>
Some text
</div>
<script type="text/javascript">
var theHandle = document.getElementById("handle");
var theRoot = document.getElementById("root");
Drag.init(theHandle, theRoot);
</script>
When you view the source of the example page above, notice how while most of the CSS for the DIV is defined in the HEAD section of the page, at the very least, the "top" and "left" properties to affect initial positioning need to be defined inside the <DIV> tag itself. Limiting the range of the drag You can also set up the drag behavior in a way so the dragging is limited by range, whether vertically or horizontally. This is useful, for example, when you're creating an artificial scrollbar, and it should only be allowed to be dragged vertically or horizontally a certain distance. <div id="thumb" style="position: relative; left:0; top:0;"></div>
<script language="javascript">
var aThumb = document.getElementById("thumb");
Drag.init(aThumb, null, 0, 300, 0, 0);
</script>
See another example. (absolutely positioned scrollbar instead of relative). Those 4 numbers at the end are the constraining rectangle of the draggable object. They go in the order: minX, maxX, minY, maxY. You can set some of them to null to tell DOM-Drag that motion in that direction should not be constrained. Note also how we have set the root object parameter to null in this case, since the thumb is not a handle for anything. Drag and react What good is dragging if it your page cant be aware of and react to this action? DOM-Drag fires three events into the environment that you can tap into: .onDragStart(x,y) These custom event handlers allow your page to react to the dragging in any fashion your creativity takes you. Take a look at this script to see how to use some of these event handlers: <script language="javascript">
var aThumbv = document.getElementById("thumbv");
var scrolldiv=document.getElementById("scrollcontent");
Drag.init(aThumbv, null, 0, 0, 0, 150);
aThumbv.onDrag = function(x, y) {// x, y contains current offset coords of drag
scrolldiv.style.top=y * (-1) +"px";
}
</script>
Some text Some text Some text Some text Some text Some text Some text Some text Some text "x" and "y" above contain the horizontal and vertical position of the scrollbar relative to its original position. |
YUI Color Picker |
Date Added: 2007-05-18 |
| -User Submitted Need a color picker for your online forms or application? This advanced color picker is based on Yahoo's excellent UI library, and features a fully interactive, drag and drop... | |
ColorJack DHTML color picker |
Date Added: 2007-05-18 |
| -User Submitted ColorJack DHTML color picker is a cross browser, sleek color picker that's compact to boot. Licensed under Creative Commons, use it on your sites or web apps.... | |
pathGenerator |
Date Added: 2007-06-16 |
| -User Submitted _pathGenerator is an online wizard that allows anyone to easily create an animating layer that follows any desired path. Just drag your mouse to map out its course,... | |
VML Editor |
Date Added: 2007-06-16 |
| -User Submitted VML (Vector Markup Language) is a text based vector graphics format proprietary to Internet Explorer. Jacco has created the following powerful VML editor to allow you to use your... | |
Time-based Progress Bar |
Date Added: 2007-06-16 |
| -User Submitted This is a fully customizable "time based" progress bar. Set any duration (ie: 10 seconds) for the script to finish loading the bar. A great script to prov... | |
Event-based Progress Bar |
Date Added: 2007-06-16 |
| -User Submitted This is an event-based progress bar which you can add to existing scripts that require graphical representation. Using 3 pre-exposed methods, you control prec... | |
WinXP Progress Bar |
Date Added: 2007-06-16 |
| -User Submitted A great looking pure DHTML progress bar that resembles the one seen in Window XP's startup screen. All visual aspects of the bar can be customized, and the script can ... | |
Pie Graph script |
Date Added: 2007-06-16 |
| -User Submitted This is a purely DHTML/ CSS based Pie Graph script. It loads fast and blends in with the rest of the page.... | |
Line Graph script |
Date Added: 2007-06-16 |
| -User Submitted Based on the same library as the Pie Graph script, this is a purely DHTML/ CSS based Line Graph script. It loads fast and blends in with the rest of the page.... | |
Find In Page Script |
Date Added: 2007-06-16 |
| -User Submitted This cross browser DHTML script simulates the Edit> Find In Page feature of the browser to allow your visitors to easily search for a particular text on your page.&nb... | |
Tip of the day dialog |
Date Added: 2007-06-16 |
| -User Submitted Provide daily tidbits of interesting information to your visitors, in an even more interesting way, with this ultimate tip of the day script!... | |
Copy text to clipboard script |
Date Added: 2007-06-16 |
| -User Submitted This "demo" script does two things: 1) identifies the selected text on the page 2) copies this text to clipboard. As part of a larger application... | |
onMouseover scrollbar effect |
Date Added: 2007-06-16 |
| -User Submitted Use this unique script to apply a rollover effect to your webpage's scrollbar!... | |
Ajax load XML file script |
Date Added: 2007-06-16 |
| -User Submitted This script demonstrates the concept of using Ajax to load a simple XML file and display it on the page.... | |
Gradient Bar |
Date Added: 2007-06-16 |
| -User Submitted An impressive demonstration of using DHTML code to render a gradient bar. Easily change the bar's color, position and direction, all through the setting of a few variabl... | |
| 1. JavaScript Gravity |
| JavaScript Gravity allows you to create the effect of an obj |
| 2. Expanding Elements |
| Expanding Elements script can be used to allow elements such |
| 3. YUI Test |
| YUI Test is a testing framework for browser-based JavaScript |
| 4. jRails |
| jRails is a drop-in jQuery replacement for the Rails Prototy |
| 5. Select Box Replacement |
| Select Box Replacement is an unobtrusive jQuery plugin that |
| 6. jQuery Field Plug-in |
| jQuery Field Plug-in expands the ability to retrieve and set |
| 7. inlineEdit.v3.js |
| inlineEdit.v3.js is a simple to use MooTools plugin that all |
| 8. Animated InnerFade with JQuery |
| Animated InnerFade with JQuery script is a full W3C complian |
| 9. MooFlow |
| MooFlow is an AJAX based image gallery that uses MooTools. |
| 10. jQuery Plugin SVG |
| jQuery SVG is a jQuery plugin that lets you easily interact |
| 11. HeatColor |
| HeatColor is a plugin that allows you to assign colors to el |
| 12. YUI Charts Control |
| YUI Charts Control visualizes tabular data on a web page in |
| 13. JavaScript Info Pane |
| JavaScript Info Pane is designed to look and act much like a |
| 14. Corner Dock Navigation |
| Corner Dock Navigation is a dock style navigation menu that |
| 15. Auto Suggest Box |
| Auto Suggest Box is a normal text input box which automatica |
| 16. MinMax Elements |
| MinMax Elements JavaScript allows you to get a windows like |
| 17. jQuery Column Filters |
| jQuery Column Filters provides a quick way of allowing table |
| 18. FastFind Menu Script |
| FastFind Menu Script script allows you to create nested menu |
| 19. jGrowl |
| jGrowl is a jQuery plugin that raises unobtrusive messages w |
| 20. Cookie Crumbs |
| Cookie Crumbs JavaScript creates a breadcrumb type trail of |
| 1. Ots Studio |
| Ots Studio - Ripper, Encoder & Ots Media File Editor. Ots... |
| 2. Analogue Clock |
| Analogue Clock is a clear analogue clock, written in AS 2.0,... |
| 3. Photo Frame Show |
| Photo Frame Show is an imaging and desktop enhancement progr... |
| 4. Image panning v.2 |
| Simple image panning tool - just load an image with any size... |
| 5. Sib Icon Extractor |
| Sib Icon Extractor is a handy and reliable tool for extracti... |
| 6. Sib Icon Editor |
| Sib Icon Editor is a power-packed icon editor featuring abil... |
| 7. Free AVI to MP2 Converter |
| Doremisoft Free AVI to MP2 Converter is an easiy-to-use medi... |
| 8. Advanced TIFF Editor |
| Advanced TIFF Editor - feature-rich FAX, TIF (TIFF), PDF, EP... |
| 9. A-Z Planner |
| A-Z Planner is an advanced, multi-functional tool that allow... |
| 10. Public PC Desktop |
| Use Public PC Desktop to turn your personal computer into an... |
Leave a comment