
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
draggabilly
Advanced tools
Make that shiz draggable
Rad because it supports IE8+ and multi-touch.
Grab a packaged source file:
Or if you're cool with the command line, install with Bower.
bower install draggabilly
var elem = document.querySelector('#draggable');
var draggie = new Draggabilly( elem, {
// options...
});
When dragging, Draggabillly will add the class .is-dragging
to the element.
Type: String
Values: 'x'
or 'y'
axis: 'x'
Constrains movement to horizontal or vertical axis.
Type: Element, Selector String, or Boolean
containment: '#container'
Contains movement to the bounds of the element. If true
, the container will be the parent element.
Type: Array
Values: [ x, y ]
grid: [ 20, 20 ]
Snaps the element to a grid, every x and y pixels.
Type: Selector String
handle: '.handle'
Specifies on what element the drag interaction starts.
handle
is useful for when you do not want all inner elements to be used for dragging, like inputs and forms. See back handle example on CodePen.
Draggabilly is an Event Emitter. You can bind event listeners to events.
var draggie = new Draggabilly( elem );
function onDragMove( instance, event, pointer ) {
console.log( 'dragMove on ' + event.type +
pointer.pageX + ', ' + pointer.pageY +
' position at ' + instance.position.x + ', ' + instance.position.y );
}
// bind event listener
draggie.on( 'dragMove', onDragMove );
// un-bind event listener
draggie.off( 'dragMove', onDragMove );
// return true to trigger an event listener just once
draggie.once( 'dragMove', function() {
console.log('Draggabilly did move, just once');
});
.on( 'dragStart', function( draggieInstance, event, pointer ) { //...
draggieInstance
- Type: Draggabilly - the Draggabilly instanceevent
- Type: Event - the original mousedown
or touchstart
eventpointer
- Type: MouseEvent or Touch - the event object that has .pageX
and .pageY
.on( 'dragMove', function( draggieInstance, event, pointer ) { //...
draggieInstance
- Type: Draggabilly - the Draggabilly instanceevent
- Type: Event - the original mousemove
or touchmove
eventpointer
- Type: MouseEvent or Touch - the event object that has .pageX
and .pageY
.on( 'dragEnd', function( draggieInstance, event, pointer ) { //...
draggieInstance
- Type: Draggabilly - the Draggabilly instanceevent
- Type: Event - the original mouseup
or touchend
eventpointer
- Type: MouseEvent or Touch - the event object that has .pageX
and .pageY
draggie.disable()
draggie.enable()
Draggabilly works with RequireJS.
You can require draggabilly.pkgd.js.
requirejs( [
'path/to/draggabilly.pkgd.js',
], function( Draggabilly ) {
new Draggabilly( ... );
});
Or, you can manage dependencies with Bower. Set baseUrl
to bower_components
and set a path config for all your application code.
requirejs.config({
baseUrl: 'bower_components/',
paths: { // path your your app
app: '../'
}
});
requirejs( [
'draggabilly/draggabilly',
'app/my-component.js'
], function( Draggabilly, myComp ) {
new Draggabilly( ... );
});
Draggabilly is released under the MIT License. Have at it.
FAQs
make that shiz draggable
The npm package draggabilly receives a total of 51,784 weekly downloads. As such, draggabilly popularity was classified as popular.
We found that draggabilly demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.