Drag Docs

The FORK.Drag object contains a collection of modular code blocks that you connect together to create your desired dragdrop behavior. It is like playing with LEGO. Once you get to know how the pieces work and how they fit together you can create great works with minimal code. I created this code to be the fastest, most flexible, lightest dragdrop library in existence. It really does take a completely different approach then other dragdrop libraries. The Drag library uses simple object-oriented concepts to make the magic happen.

The best way to get started with the Drag library is look at the source of some examples on the test page. There are many comments in the source files from an older attempt to document the library.

The first thing you might notice is there are no "interesting moment hooks" like in the Yahoo! UI and Scriptaculous drag libraries. There is no way to predict where you or I will need interesting moment hooks in our next projects. Instead of hooks, the functions in the drag library are kept very small. If you need to override a small portion of code you can do it. If you need to extend the functionality of one function you can use FORK.extend and use calls to superPrototype. This is aspect-oriented programming-ish. There are also no configuration parameters. If you want to change one of the defaults you can just override that default. JavaScript is fun that way:D It is extremely flexible and fast to create unique behavior. You are not locked into a library with a certain set of features that is difficult to modify and hence bloats as users request more hooks and configuration options.

I would like to include some facade interfaces to the Drag library for common user interfaces like certain kinds of sortable list eventually. Creating elegant sortable list code is challenging. I do have some examples I will add to the tests page.

More reading http://peter.michaux.ca/article/51 when I initially released this project independently. Be sure to look at the Jelly Donut Example

More docs to come later but it is really worth the time to read and become familiar with the code base if you want to leverage this library to the maximum. It is not really a lot of code to learn which is a big part of its charm. I think the Drag library is the sparkling jewel in the Fork code base.

Netscape Navigator 6.0 can use the drag library as shown in the test page examples. However Navigator 6.0 does not support CSS's position:absolute like Navigator 6.1 and up do. You can feature test for support of the absolute value by positioning an element using absolute and then determining if the element is where it is expected to be. A bit of work but it should work.

Many browsers past and present do not report one or all of the alt/shift/cmd/meta keys for a mouse event. This makes multiple selection difficult in the way people are used to their computer working.

Credits

A long discussion with Tim Hosking about delegated events. An enlightening discussion with Richard Cornford about modular library design. Some ideas from the Yahoo! UI dragdrop utility were also incorporated.