Skip to content

Commit b7d7c00

Browse files
committed
improved redraw api
1 parent 0872657 commit b7d7c00

File tree

3 files changed

+3
-17
lines changed

3 files changed

+3
-17
lines changed

demo/app.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
angular.module('app', ['jtt_bricklayer']);
22

33
angular.module('app')
4-
.controller("appController", function ($scope, $timeout) {
5-
$scope.createElement = function (position) {
4+
.controller("appController", function ($scope) {
5+
$scope.createElement = function () {
66
return {
77
color: '#' + Math.random().toString(16).substr(-6),
88
height: sizes[Math.floor(Math.random() * sizes.length)],
@@ -16,10 +16,6 @@ angular.module('app')
1616
$scope.data.push($scope.createElement());
1717
};
1818

19-
$scope.reorderElements = function () {
20-
$scope.$emit('bricklayer.reorderElements');
21-
};
22-
2319
var sizes = [220, 250, 260, 270, 290, 300, 310, 330, 400, 430, 450, 480, 500];
2420

2521
for (var i = 0; i < 10; i++) {

demo/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
<iframe src="https://ghbtns.com/github-btn.html?user=JohnnyTheTank&repo=angular-bricklayer&type=star&count=true&size=large" frameborder="0" scrolling="0" width="160px" height="30px"></iframe>
6363

6464
<button ng-click="appendNew()"><strong>Append Item</strong></button>
65-
<button ng-click="reorderElements()"><strong>Reorder Elements</strong></button>
6665

6766
<!-- Bricklayer needs to have "bricklayer" class name. -->
6867
<div class="bricklayer">

src/angular-bricklayer.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,15 @@ angular.module('jtt_bricklayer', [])
1212
scope.$on('bricklayer.append', function (event, element) {
1313
bricklayer.append(element);
1414
bricklayer.redraw();
15-
$timeout(function () {
16-
bricklayer.redraw();
17-
});
1815
});
1916

2017
scope.$on('bricklayer.prepend', function (event, element) {
2118
bricklayer.prepend(element);
2219
bricklayer.redraw();
23-
$timeout(function () {
24-
bricklayer.redraw();
25-
});
2620
});
2721

28-
scope.$on('bricklayer.reorderElements', function () {
22+
scope.$on('bricklayer.redraw', function () {
2923
bricklayer.redraw();
30-
$timeout(function () {
31-
bricklayer.redraw();
32-
});
3324
});
3425
}
3526
}

0 commit comments

Comments
 (0)