Skip to content

Commit 2ce9bfb

Browse files
committed
added redraw functionality
1 parent 40831f8 commit 2ce9bfb

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

src/angular-bricklayer.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
angular.module('jtt_bricklayer', [])
2-
.directive('bricklayer', function () {
2+
.directive('bricklayer', ['$timeout', function ($timeout) {
33
return {
44
restrict: 'C',
55
replace: 'false',
66
link: function (scope, element, attrs) {
77
var bricklayer = new Bricklayer(element[0]);
88

9+
$timeout(function () {
10+
bricklayer.reorderElements(bricklayer.columnCount);
11+
}, 0);
12+
913
scope.$on('bricklayer.append', function (event, element) {
10-
setTimeout(function () {
11-
bricklayer.append(element)
12-
}, 0)
14+
bricklayer.append(element);
15+
bricklayer.reorderElements(bricklayer.columnCount);
16+
$timeout(function () {
17+
bricklayer.reorderElements(bricklayer.columnCount);
18+
}, 0);
1319
});
1420

1521
scope.$on('bricklayer.prepend', function (event, element) {
16-
setTimeout(function () {
17-
bricklayer.prepend(element)
18-
}, 0)
22+
bricklayer.prepend(element);
23+
bricklayer.reorderElements(bricklayer.columnCount);
24+
$timeout(function () {
25+
bricklayer.reorderElements(bricklayer.columnCount);
26+
}, 0);
1927
});
2028
}
2129
}
22-
})
30+
}])
2331
.directive('bricklayerAppend', function () {
2432
return {
2533
require: '?bricklayer',

0 commit comments

Comments
 (0)