Skip to content

Commit

Permalink
add jQuery bridget; jQuery browserify example
Browse files Browse the repository at this point in the history
add jquery bridget as devDependency
  • Loading branch information
desandro committed Nov 21, 2014
1 parent 639d979 commit 9f20166
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"draggabilly": "1.x",
"jquery": "~1",
"jquery-ui-draggable": "https://gist.github.com/4985610.git",
"jquery-bridget": "1.1.x",
"qunit": "^1.15"
},
"ignore": [
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"devDependencies": {
"draggabilly": "1.x",
"jquery": "~1",
"jquery-bridget": "1.1.x",
"qunitjs": "^1.15",
"grunt": "~0.4.0",
"grunt-contrib-jshint": "~0.4.1",
Expand All @@ -30,6 +31,8 @@
"url": "git://github.com/metafizzy/packery.git"
},
"keywords": [
"DOM",
"browser",
"layout",
"bin",
"binpacking",
Expand Down
24 changes: 24 additions & 0 deletions sandbox/browserify/jquery-main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// ----- jQuery ----- //

var Packery = require('../../js/packery');
var Draggabilly = require('draggabilly');
var $ = require('jquery');
var jQBridget = require('jquery-bridget');

$.bridget( 'packery', Packery );

var $container = $('#basic').packery({
columnWidth: 50,
rowHeight: 50
});

var pckry = $container.data('packery');

$.each( pckry.items, function( i, item ) {
var draggie = new Draggabilly( item.element );
$container.packery( 'bindDraggabillyEvents', draggie );
});

$container.packery( 'on', 'dragItemPositioned', function( pckry, item ) {
console.log( 'drag item positioned', item.position.x, item.position.y );
});
2 changes: 0 additions & 2 deletions sandbox/browserify/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,3 @@ for ( var i=0, len = pckry.items.length; i < len; i++ ) {
pckry.on( 'dragItemPositioned', function( pckry, item ) {
console.log( 'drag item positioned', item.position.x, item.position.y );
});

// ----- jQuery ----- //

0 comments on commit 9f20166

Please sign in to comment.