From 9f20166b1414589a8e46bf53aeadfffbcadf13fd Mon Sep 17 00:00:00 2001 From: David DeSandro Date: Fri, 21 Nov 2014 17:21:42 -0500 Subject: [PATCH] add jQuery bridget; jQuery browserify example add jquery bridget as devDependency --- bower.json | 1 + package.json | 3 +++ sandbox/browserify/jquery-main.js | 24 ++++++++++++++++++++++++ sandbox/browserify/main.js | 2 -- 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 sandbox/browserify/jquery-main.js diff --git a/bower.json b/bower.json index 3a1d646..6e62c49 100644 --- a/bower.json +++ b/bower.json @@ -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": [ diff --git a/package.json b/package.json index 3c2b222..2e4063e 100644 --- a/package.json +++ b/package.json @@ -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", @@ -30,6 +31,8 @@ "url": "git://github.com/metafizzy/packery.git" }, "keywords": [ + "DOM", + "browser", "layout", "bin", "binpacking", diff --git a/sandbox/browserify/jquery-main.js b/sandbox/browserify/jquery-main.js new file mode 100644 index 0000000..dccffb6 --- /dev/null +++ b/sandbox/browserify/jquery-main.js @@ -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 ); +}); diff --git a/sandbox/browserify/main.js b/sandbox/browserify/main.js index a9467ae..a6be43d 100644 --- a/sandbox/browserify/main.js +++ b/sandbox/browserify/main.js @@ -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 ----- //