Skip to content

Commit 33ccbe2

Browse files
committed
improved demo
1 parent 2ce9bfb commit 33ccbe2

2 files changed

Lines changed: 36 additions & 19 deletions

File tree

demo/app.js

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

33
angular.module('app')
44
.controller("appController", function ($scope, $timeout) {
5+
$scope.createElement = function (position) {
6+
return {
7+
color: '#' + Math.random().toString(16).substr(-6),
8+
height: sizes[Math.floor(Math.random() * sizes.length)],
9+
width: sizes[Math.floor(Math.random() * sizes.length)],
10+
}
11+
};
12+
513
$scope.data = [];
614

7-
var heights = [30, 40, 50, 60, 70, 90, 100, 120, 150, 200];
15+
$scope.appendNew = function () {
16+
$scope.data.push($scope.createElement());
17+
};
818

9-
for (var i = 0; i < 60; i++) {
10-
$scope.data.push({
11-
color: '#' + Math.random().toString(16).substr(-6),
12-
height: heights[Math.floor(Math.random() * heights.length)],
13-
});
19+
var sizes = [220, 250, 260, 270, 290, 300, 310, 330, 400, 430, 450, 480, 500];
20+
21+
for (var i = 0; i < 10; i++) {
22+
$scope.appendNew();
1423
}
24+
25+
1526
});

demo/index.html

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<head>
44
<meta charset="utf-8">
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6-
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
7+
78

89
<title>angular-bricklayer</title>
910

@@ -25,27 +26,33 @@
2526
/* Bricklayer calculates its column sizes from the `bricklayer-column-sizer` element. You can give it some width with media queries to make it responsive */
2627
@media screen and (min-width: 300px) {
2728
.bricklayer-column-sizer {
28-
/* If page is greater than 300px, columns will be 20% wide. */
29-
width: 20%;
29+
width: 33.333%;
3030
}
3131
}
3232

3333
@media screen and (min-width: 400px) {
3434
.bricklayer-column-sizer {
35-
/* If page is greater than 400px, columns will be 10% wide, which are more narrow. */
36-
width: 10%;
35+
width: 25%;
3736
}
3837
}
3938

4039
@media screen and (min-width: 700px) {
4140
.bricklayer-column-sizer {
42-
/* If page is greater than 700px, columns will be 5% wide. That means there will be lots of columns */
43-
width: 5%;
41+
width: 20%;
4442
}
4543
}
4644

4745
.box {
4846
margin: 10px 0;
47+
padding: 10px;
48+
border: 1px solid black;
49+
}
50+
51+
img {
52+
width: 100%;
53+
height: auto;
54+
border: 1px solid black;
55+
display:block;
4956
}
5057
</style>
5158

@@ -54,14 +61,13 @@
5461

5562
<!-- Bricklayer needs to have "bricklayer" class name. -->
5663

64+
<button ng-click="appendNew()"><strong>Append Item</strong></button>
65+
5766
<div class="bricklayer">
58-
<div class="box" style="background-color: red; height: 100px"></div>
59-
<div class="box" style="background-color: green; height: 70px"></div>
60-
<div class="box" style="background-color: blue; height: 30px"></div>
61-
<div class="box" style="background-color: orange; height: 40px"></div>
62-
<div class="box" bricklayer-append style="background-color: {{item.color}}; height: {{item.height + 'px'}}" ng-repeat="item in data"></div>
67+
<div class="box" bricklayer-append ng-repeat="item in data" style="background-color: {{item.color}};">
68+
<img ng-src="http://lorempixel.com/{{item.width}}/{{item.height}}">
69+
</div>
6370
</div>
6471

65-
6672
</body>
6773
</html>

0 commit comments

Comments
 (0)