| Index: third_party/pkg/angular/demo/bouncing_balls/web/bouncy_balls.dart
|
| diff --git a/third_party/pkg/angular/example/web/bouncing_balls.dart b/third_party/pkg/angular/demo/bouncing_balls/web/bouncy_balls.dart
|
| similarity index 74%
|
| rename from third_party/pkg/angular/example/web/bouncing_balls.dart
|
| rename to third_party/pkg/angular/demo/bouncing_balls/web/bouncy_balls.dart
|
| index d6145295121502ffe09e9a15e8078984afa812d7..783769740af66a8a43784333c44a4483f594f228 100644
|
| --- a/third_party/pkg/angular/example/web/bouncing_balls.dart
|
| +++ b/third_party/pkg/angular/demo/bouncing_balls/web/bouncy_balls.dart
|
| @@ -1,5 +1,4 @@
|
| import 'package:angular/angular.dart';
|
| -import 'package:angular/application_factory.dart';
|
| import 'dart:html';
|
| import 'dart:math';
|
| import 'dart:core';
|
| @@ -26,22 +25,23 @@ class BallModel {
|
|
|
| }
|
|
|
| -@Controller(
|
| +@NgController(
|
| selector: '[bounce-controller]',
|
| publishAs: 'bounce')
|
| class BounceController {
|
| var lastTime = window.performance.now();
|
| - var run = false;
|
| + var run = true;
|
| var fps = 0;
|
| var digestTime = 0;
|
| var currentDigestTime = 0;
|
| var balls = [];
|
| + final NgZone zone;
|
| final Scope scope;
|
| var ballClassName = 'ball';
|
|
|
| - BounceController(this.scope) {
|
| + BounceController(this.zone, this.scope) {
|
| changeCount(100);
|
| - if (run) tick();
|
| + tick();
|
| }
|
|
|
| void toggleCSS() {
|
| @@ -54,7 +54,7 @@ class BounceController {
|
| }
|
|
|
| void requestAnimationFrame(fn) {
|
| - window.requestAnimationFrame((_) => fn());
|
| + window.requestAnimationFrame((_) => zone.run(fn));
|
| }
|
|
|
| void changeCount(count) {
|
| @@ -97,38 +97,41 @@ class BounceController {
|
| }
|
| }
|
|
|
| -List<String> _CACHE = new List.generate(500, (i) => '${i}px');
|
| -
|
| -@Decorator(
|
| +@NgDirective(
|
| selector: '[ball-position]',
|
| map: const {
|
| - "ball-position": '=>position'},
|
| - exportExpressions: const ['x', 'y'])
|
| -class BallPosition {
|
| + "ball-position": '=>position'})
|
| +class BallPositionDirective {
|
| final Element element;
|
| final Scope scope;
|
| - BallPosition(this.element, this.scope);
|
| -
|
| - px(x) => _CACHE[max(0, x.round())];
|
| + BallPositionDirective(this.element, this.scope);
|
|
|
| set position(BallModel model) {
|
| - var style = element.style;
|
| - style.backgroundColor = model.color;
|
| + element.style.backgroundColor = model.color;
|
| scope
|
| - ..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);
|
| + ..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);
|
| }
|
| }
|
|
|
| class MyModule extends Module {
|
| MyModule() {
|
| type(BounceController);
|
| - type(BallPosition);
|
| + 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));
|
| }
|
| }
|
|
|
| main() {
|
| - applicationFactory().addModule(new MyModule()).run();
|
| + ngBootstrap(module: new MyModule());
|
| }
|
|
|