angular-draggabilly
v0.0.4
Published
An angular wrapper for Draggabilly
Downloads
1,276
Maintainers
Readme
Angular Draggabilly directive - drag and drop for Angular
This is an angular wrapper to Draggabilly.
Does not create its own scope and does not pollute the parent scope.
And for all the ones that are curious about whether this one needs jquery-ui:
look ma, no jQuery!
Usage
- The simplest form (just a draggable element)
<div draggabilly>Drag me</div>
Dependencies
Angular Draggabilly needs the Draggabilly library and its dependencies.
- You can either install everything via bower (and if your package management resolves transitive packages you are good to go)
- or you can use the packaged version of Draggabilly and the dist version of Angular Draggabilly.
- or in the case of manual install, just add:
'bower_components/classie/classie.js',
'bower_components/eventEmitter/EventEmitter.js',
'bower_components/eventie/eventie.js',
'bower_components/get-style-property/get-style-property.js',
'bower_components/get-size/get-size.js',
'bower_components/draggabilly/draggabilly.js',
'bower_components/angular-draggabilly/dist/angular-draggabilly.js'
Options
- locking to axes
<div draggabilly draggie-axis="y">Drag me vertically</div>
<div draggabilly draggie-axis="x">Drag me horizontally</div>
- containment in other elements
<div id="container" style="width: 200px; height: 200px; background-color: red;">
<div draggabilly draggie-containment="'#container'">x</div>
<div draggabilly draggie-containment="true">o</div>
</div>
- snapping to grid
<div draggabilly draggie-grid="[20, 20]">Snap me to a grid</div>
- dragging by handle
<div draggabilly draggie-handle="#handle" style="background-color: blue; width: 100px; height: 100px;">
<div id="handle" style="background-color: red; width: 20px; height: 20px; position: relative; left: 40px; top: 40px;"></div>
</div>
Events
var handler = function($event, instance, originalEvent, pointer) {
console.log('The element', instance.element, 'is now at', instance.position.x, instance.position.y);
};
$rootScope.$on('draggie.start', handler);
$rootScope.$on('draggie.move', handler);
$rootScope.$on('draggie.end', handler);
By default, all events are emitted, however eventing can be disabled (and should be if not used, because it saves quite a few digest cycles) by adding draggie-events=""
or selectively enabled by using start
, move
and end
, e.g. draggie-events="start,end"
.
Demo
You can start a demo server with grunt demo
and go to localhost:8000/demo to test the directive.
Grunt Tasks
Initialize with
npm install
and then use the various tasks:
grunt
: Execute testsgrunt coverage
: Serve coverage report on port 7000grunt test
: Just testgrunt test:e2e
: Just test end to endgrunt test:unit
: Just test unitgrunt tdd
: Watch source and test files and run testsgrunt tdd:e2e
: Watch and test just end to endgrunt tdd:unit
: Watch and test just unitgrunt build
: Just buildgrunt release
: Test, build, bump patch version, commit, add version tag and push
test
tasks have a --browsers
option to specify the browsers you want to use
Browsers can also be set by the following environment-variables
PROTRACTOR_BROWSERS=Firefox,Chrome
KARMA_BROWSERS=Firefox,PhantomJS
See Gruntfile.js and tasks/options for all task details.
LICENSE
The MIT License
Copyright (c) 2014 Jimdo GmbH http://jimdo.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.