Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Unified Diff: third_party/pkg/angular/example/web/bouncing_balls.dart

Issue 257423008: Update all Angular libs (run update_all.sh). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/pkg/angular/example/web/bouncing_balls.dart
diff --git a/third_party/pkg/angular/demo/bouncing_balls/web/bouncy_balls.dart b/third_party/pkg/angular/example/web/bouncing_balls.dart
similarity index 74%
rename from third_party/pkg/angular/demo/bouncing_balls/web/bouncy_balls.dart
rename to third_party/pkg/angular/example/web/bouncing_balls.dart
index 783769740af66a8a43784333c44a4483f594f228..d6145295121502ffe09e9a15e8078984afa812d7 100644
--- a/third_party/pkg/angular/demo/bouncing_balls/web/bouncy_balls.dart
+++ b/third_party/pkg/angular/example/web/bouncing_balls.dart
@@ -1,4 +1,5 @@
import 'package:angular/angular.dart';
+import 'package:angular/application_factory.dart';
import 'dart:html';
import 'dart:math';
import 'dart:core';
@@ -25,23 +26,22 @@ class BallModel {
}
-@NgController(
+@Controller(
selector: '[bounce-controller]',
publishAs: 'bounce')
class BounceController {
var lastTime = window.performance.now();
- var run = true;
+ var run = false;
var fps = 0;
var digestTime = 0;
var currentDigestTime = 0;
var balls = [];
- final NgZone zone;
final Scope scope;
var ballClassName = 'ball';
- BounceController(this.zone, this.scope) {
+ BounceController(this.scope) {
changeCount(100);
- tick();
+ if (run) tick();
}
void toggleCSS() {
@@ -54,7 +54,7 @@ class BounceController {
}
void requestAnimationFrame(fn) {
- window.requestAnimationFrame((_) => zone.run(fn));
+ window.requestAnimationFrame((_) => fn());
}
void changeCount(count) {
@@ -97,41 +97,38 @@ class BounceController {
}
}
-@NgDirective(
+List<String> _CACHE = new List.generate(500, (i) => '${i}px');
+
+@Decorator(
selector: '[ball-position]',
map: const {
- "ball-position": '=>position'})
-class BallPositionDirective {
+ "ball-position": '=>position'},
+ exportExpressions: const ['x', 'y'])
+class BallPosition {
final Element element;
final Scope scope;
- BallPositionDirective(this.element, this.scope);
+ BallPosition(this.element, this.scope);
+
+ px(x) => _CACHE[max(0, x.round())];
set position(BallModel model) {
- element.style.backgroundColor = model.color;
+ var style = element.style;
+ style.backgroundColor = model.color;
scope
- ..watch('x', (x, _) => element.style.left = '${x + 10}px', context: model, readOnly: true)
- ..watch('y', (y, _) => element.style.top = '${y + 10}px', context: model, readOnly: true);
+ ..watch('x', (x, _) => element.style.left = '${x + 10}px',
+ context: model, canChangeModel: false)
+ ..watch('y', (y, _) => element.style.top = '${y + 10}px',
+ context: model, canChangeModel: false);
}
}
class MyModule extends Module {
MyModule() {
type(BounceController);
- type(BallPositionDirective);
- value(GetterCache, new GetterCache({
- 'x': (o) => o.x,
- 'y': (o) => o.y,
- 'bounce': (o) => o.bounce,
- 'fps': (o) => o.fps,
- 'balls': (o) => o.balls,
- 'length': (o) => o.length,
- 'digestTime': (o) => o.digestTime,
- 'ballClassName': (o) => o.ballClassName
- }));
- value(ScopeStats, new ScopeStats(report: true));
+ type(BallPosition);
}
}
main() {
- ngBootstrap(module: new MyModule());
+ applicationFactory().addModule(new MyModule()).run();
}

Powered by Google App Engine
This is Rietveld 408576698