Skip to content

Commit

Permalink
added redraw functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyTheTank committed Apr 23, 2016
1 parent 40831f8 commit 2ce9bfb
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/angular-bricklayer.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
angular.module('jtt_bricklayer', [])
.directive('bricklayer', function () {
.directive('bricklayer', ['$timeout', function ($timeout) {
return {
restrict: 'C',
replace: 'false',
link: function (scope, element, attrs) {
var bricklayer = new Bricklayer(element[0]);

$timeout(function () {
bricklayer.reorderElements(bricklayer.columnCount);
}, 0);

scope.$on('bricklayer.append', function (event, element) {
setTimeout(function () {
bricklayer.append(element)
}, 0)
bricklayer.append(element);
bricklayer.reorderElements(bricklayer.columnCount);
$timeout(function () {
bricklayer.reorderElements(bricklayer.columnCount);
}, 0);
});

scope.$on('bricklayer.prepend', function (event, element) {
setTimeout(function () {
bricklayer.prepend(element)
}, 0)
bricklayer.prepend(element);
bricklayer.reorderElements(bricklayer.columnCount);
$timeout(function () {
bricklayer.reorderElements(bricklayer.columnCount);
}, 0);
});
}
}
})
}])
.directive('bricklayerAppend', function () {
return {
require: '?bricklayer',
Expand Down

0 comments on commit 2ce9bfb

Please sign in to comment.