NOTE As of May 2022 this project has been archived. No development work has been done for 18 months or so as the drag handling code in jsPlumb has been moved to a module in the 5.x branch.
Katavorio is a lightweight drag/drop handler, supporting containment, multiple element drag, custom css classes, drop filters, drag filters, drag clones, drag handles, constraining movement to a grid, and zooming.
Katavorio does not work "out of the box" - it was developed as part of jsPlumb 1.6.0, to support a "no dependency" version (all previous versions of jsPlumb required either jQuery, MooTools or YUI, to provide a bunch of functionality such as CSS manipulation, getting/setting element positions, supporting drag/drop etc). So, rather than re-write simple methods such as addClass, removeClass, getPosition etc, Katavorio expects those methods to be provided in the constructor's options object.
All is not lost, though, as this project also contains DefaultKatavorioHelper - the set of missing methods.
npm install katavorio
NOTE: Katavorio does not follow strict semantic versioning. It is not at all recommended that you use wildcards when specifying a dependency on Katavorio.
None
If you have jsPlumb in your page then you already have Katavorio - it is bundled into jsPlumb. Otherwise you'll need to import two scripts:
node_modules/katavorio/src/default-katavorio-helper.js
node_modules/katavorio/src/katavorio.js
For more information, take a look in the wiki.
17 Sep 2020
- added a test in
elementRemoved
to check if an element is in fact draggable/droppable before running the code to de-register it.
- Changed package name to @jsplumb/katavorio
- support constrain functions in a drag selector
- support ghost proxy handling by selectors in a drag.
- return grid position from snap method on draggable.
- support filter and filterExclude in delegated drag handlers
- pass current drag element in callback to "should proxy" function. Required when a delegate drag is occurring.
- pass the return value of a delegate to the code that tests if a drag can begin.
- fixed an issue with drag stop event for single node drags.
- support revert function being passed in to constructor.
- added support for "combinator rooted" queries for delegated drags.
- added support for provision of
ghostProxyParent
when using a ghost proxy to drag.
- add test to ensure event's default not prevented when responding to initial mouse down
- Add support for multiple selector definitions on a single Drag object, via the new
addSelector
method. You can make some element draggable and then attach more listeners to that object, rather than having to create a whole new draggable:
let d = katavorioInstance.draggable(someElement, {
selector:".childSelector",
start:function(p) { ... },
etc
});
d.addSelector({
selector:".someOtherChildSelector",
start:function(p) { ... },
etc
});
- for delegated draggables (ie when you provide a
selector
in the params), we use the classkatavorio-delegated-draggable
now, instead of where we previously used the default draggable class ofkatavorio-draggable
. This can also be overridden in the constructor by setting the value ofdelegatedDraggable
.
- add the ability for a user to specify the parent to use when cloning a node for dragging.
- added the ability to remove specific drag/drop handlers (previous we could only completely switch off drag/drop)