Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library clock; | 5 library clock; |
| 6 | 6 |
| 7 import 'dart:html'; | 7 import 'dart:html'; |
| 8 import 'dart:math'; | 8 import 'dart:math'; |
| 9 | 9 |
| 10 part 'balls.dart'; | 10 part 'balls.dart'; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 | 40 |
| 41 CountDownClock() : | 41 CountDownClock() : |
| 42 hours = new List<ClockNumber>(2), | 42 hours = new List<ClockNumber>(2), |
| 43 minutes = new List<ClockNumber>(2), | 43 minutes = new List<ClockNumber>(2), |
| 44 seconds = new List<ClockNumber>(2), | 44 seconds = new List<ClockNumber>(2), |
| 45 displayedHour = 0, | 45 displayedHour = 0, |
| 46 displayedMinute = 0, | 46 displayedMinute = 0, |
| 47 displayedSecond = 0, | 47 displayedSecond = 0, |
| 48 balls = new Balls() { | 48 balls = new Balls() { |
| 49 var parent = query("#canvas-content"); | 49 var parent = query("#canvas-content"); |
| 50 | 50 |
|
Jacob
2012/11/02 05:00:29
remove requestLayoutFrame as well as async getComp
blois
2012/11/02 20:04:46
Not sure which getComputedStyles you're referring
| |
| 51 parent.rect.then((ElementRect r) { | 51 window.requestLayoutFrame(() { |
| 52 createNumbers(parent, r.client.width, r.client.height); | 52 createNumbers(parent, parent.clientWidth, parent.clientHeight); |
| 53 | 53 |
| 54 updateTime(new Date.now()); | 54 updateTime(new Date.now()); |
| 55 | 55 |
| 56 window.requestAnimationFrame(tick); | 56 window.requestAnimationFrame(tick); |
| 57 }); | 57 }); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void tick(int time) { | 60 void tick(int time) { |
| 61 updateTime(new Date.fromMillisecondsSinceEpoch(time)); | 61 updateTime(new Date.fromMillisecondsSinceEpoch(time)); |
| 62 balls.tick(time); | 62 balls.tick(time); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 159 void setElementPosition(Element elem, double x, double y) { | 159 void setElementPosition(Element elem, double x, double y) { |
| 160 elem.style.left = "${x}px"; | 160 elem.style.left = "${x}px"; |
| 161 elem.style.top = "${y}px"; | 161 elem.style.top = "${y}px"; |
| 162 } | 162 } |
| 163 | 163 |
| 164 void setElementSize(Element elem, double l, double t, double r, double b) { | 164 void setElementSize(Element elem, double l, double t, double r, double b) { |
| 165 setElementPosition(elem, l, t); | 165 setElementPosition(elem, l, t); |
| 166 elem.style.right = "${r}px"; | 166 elem.style.right = "${r}px"; |
| 167 elem.style.bottom = "${b}px"; | 167 elem.style.bottom = "${b}px"; |
| 168 } | 168 } |
| OLD | NEW |