Module-documentation

version 1.0.0
module: drag
maintanance: Marco Asbreuk
home
all modules

Constrained to a node

Draggable elements can be constrained by setting the attribute constrain-selector="css-selector", or using javascript by using node.plugin(ITSA.Plugins.NodeConstrain, {selector: 'css-selector'}). The plugin does nothing more than add the right attribute to the draggable Element, and it just works.

Drag the 2 rectangles: they will be constrained to their container. The first is constrained using html, the second is set up using javascript.

Code-example:

<body>
    <div class="base-container">
        <div class="container" plugin-dd="true" plugin-constrain="true" constrain-selector=".base-container"></div>
        <div id="without" class="container" plugin-dd="true"></div>
    </div>
</body>
<script src="itsabuild-min.js"></script>
<script>
    document.getElement('#without').plug('constrain', {selector: '.base-container'});
</script>
API Docs