Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 3eac327

Browse files
vicbrkirov
authored andcommitted
fix(bouncing balls): fix broken demo
fixes #1550
1 parent 1e9c910 commit 3eac327

File tree

6 files changed

+35
-92
lines changed

6 files changed

+35
-92
lines changed

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ dependencies:
1010
transformers:
1111
- angular:
1212
html_files:
13-
- web/bouncing_controller.html
13+
- web/bouncing_balls_tpl.html
1414
- web/form_controller.html
File renamed without changes.

example/web/bouncing_balls.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ class BallModel {
2020
static _color() {
2121
var color = '#';
2222
for(var i = 0; i < 6; i++) {
23-
color += (16 * random.nextDouble()).floor().toRadixString(16);
23+
color += random.nextInt(16).toRadixString(16);
2424
}
2525
return color;
2626
}
2727
}
2828

29-
@Injectable()
30-
class BounceController implements ScopeAware {
29+
@Component(
30+
selector: 'bouncing-balls',
31+
templateUrl: 'bouncing_balls_tpl.html',
32+
cssUrl: 'bouncing_balls.css')
33+
class BouncingBalls implements ScopeAware {
3134
Scope scope;
3235
var lastTime = window.performance.now();
3336
var run = false;
@@ -37,7 +40,7 @@ class BounceController implements ScopeAware {
3740
var balls = [];
3841
var ballClassName = 'ball';
3942

40-
BounceController() {
43+
BouncingBalls() {
4144
changeCount(100);
4245
}
4346

@@ -122,13 +125,12 @@ class BallPosition {
122125
class MyModule extends Module {
123126
MyModule() {
124127
bind(BallPosition);
125-
bind(BounceController);
128+
bind(BouncingBalls);
126129
}
127130
}
128131

129132
main() {
130133
applicationFactory()
131-
.rootContextType(BounceController)
132134
.addModule(new MyModule())
133135
.run();
134136
}

example/web/bouncing_balls.html

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,68 +2,9 @@
22
<html>
33
<head>
44
<title>Bouncing balls</title>
5-
<style>
6-
.balls {
7-
border: 1px solid black;
8-
width: 420px;
9-
height: 420px;
10-
margin: 5px;
11-
}
12-
13-
.ball {
14-
display: inline-block;
15-
position: absolute;
16-
width: 20px;
17-
height: 20px;
18-
border: 1px solid black;
19-
-webkit-border-radius: 10px;
20-
-moz-border-radius: 10px;
21-
border-radius: 10px;
22-
}
23-
24-
.fps-bar {
25-
width: 200px;
26-
height: 10px;
27-
border: 1px solid black;
28-
display: inline-block;
29-
margin-left: 5px;
30-
}
31-
32-
.fps {
33-
height: 10px;
34-
width: 60px;
35-
background-color: green;
36-
}
37-
</style>
385
</head>
396
<body ng-app>
40-
<div bounce-controller>
41-
<div class="balls">
42-
<div ng-repeat="ball in balls"
43-
class="{{ ballClassName }}"
44-
ball-position="ball"></div>
45-
</div>
46-
47-
<div>
48-
<div class="fps-bar">
49-
<div class="fps" ng-style-width="fps * 4 + 'px'"></div>
50-
</div>
51-
</div>
52-
53-
{{ fps }} fps. ({{ balls.length }} balls) [{{ 1000 / fps }} ms] <br>
54-
Digest: {{ digestTime }} ms<br>
55-
<a href ng-click="changeCount(1)">+1</a>
56-
<a href ng-click="changeCount(10)">+10</a>
57-
<a href ng-click="changeCount(100)">+100</a>
58-
<br>
59-
<a href ng-click="changeCount(-1)">-1</a>
60-
<a href ng-click="changeCount(-10)">-10</a>
61-
<a href ng-click="changeCount(-100)">-100</a>
62-
<br>
63-
<a href ng-click="playPause()">&#x25B6;&#10073;&#10073;</a> <br>
64-
<a href ng-click="toggleCSS()">Toggle CSS</a><br>
65-
<a href ng-click="timeDigest()">noop</a><br>
66-
</div>
7+
<bouncing-balls></bouncing-balls>
678

689
<script type="application/dart" src="bouncing_balls.dart"></script>
6910
<script src="packages/browser/dart.js"></script>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<div class="balls">
2+
<div ng-repeat="ball in balls"
3+
class="{{ ballClassName }}"
4+
ball-position="ball"></div>
5+
</div>
6+
7+
<div>
8+
<div class="fps-bar">
9+
<div class="fps" ng-style-width="fps * 4 + 'px'"></div>
10+
</div>
11+
</div>
12+
13+
{{ fps }} fps. ({{ balls.length }} balls) [ {{ fps == 0 ? '-' : (10000 / fps).toInt() / 10 }} ms] <br>
14+
Digest: {{ (digestTime * 10).toInt() / 10 }} ms<br>
15+
<button ng-click="changeCount(1)">+1</button>
16+
<button ng-click="changeCount(10)">+10</button>
17+
<button ng-click="changeCount(100)">+100</button>
18+
<br>
19+
<button ng-click="changeCount(-1)">-1</button>
20+
<button ng-click="changeCount(-10)">-10</button>
21+
<button ng-click="changeCount(-100)">-100</button>
22+
<br>
23+
<button ng-click="playPause()">&#x25B6;&#10073;&#10073;</button> <br>
24+
<button ng-click="toggleCSS()">Toggle CSS</button><br>
25+
<button ng-click="timeDigest()">noop</button><br>

example/web/bouncing_controller.html

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)