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

Side by Side Diff: client/samples/total/src/ZoomTracker.dart

Issue 8835006: New version of dart:html (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix typos Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 typedef void ZoomListener(double oldZoom, double newZoom); 5 typedef void ZoomListener(double oldZoom, double newZoom);
6 6
7 /** 7 /**
8 * This class tracks changing zoom factor in browser and notifies about this asy nchroniously. 8 * This class tracks changing zoom factor in browser and notifies about this asy nchroniously.
9 */ 9 */
10 class ZoomTracker { 10 class ZoomTracker {
11 List<ZoomListener> _listeners; 11 List<ZoomListener> _listeners;
12 Window _window; 12 Window _window;
13 Point _zeroPoint; 13 Point _zeroPoint;
14 double _zoom; 14 double _zoom;
15 Element _zoomElement; 15 Element _zoomElement;
16 16
17 ZoomTracker(this._window) { 17 ZoomTracker(this._window) {
18 _listeners = new List<ZoomListener>(); 18 _listeners = new List<ZoomListener>();
19 // Append element with known CSS location 19 // Append element with known CSS location
20 _zoomElement = _window.document.createElement("div"); 20 _zoomElement = new Element.tag("div");
21 _zoomElement.id = "zoomTracker"; 21 _zoomElement.id = "zoomTracker";
22 _zoomElement.style.setProperty("position", "absolute"); 22 _zoomElement.style.setProperty("position", "absolute");
23 _zoomElement.style.setProperty("top", "-100px"); 23 _zoomElement.style.setProperty("top", "-100px");
24 _zoomElement.style.setProperty("height", "0px"); 24 _zoomElement.style.setProperty("height", "0px");
25 _zoomElement.style.setProperty("visibility", "hidden"); 25 _zoomElement.style.setProperty("visibility", "hidden");
26 _window.document.body.nodes.add(_zoomElement); 26 _window.document.body.nodes.add(_zoomElement);
27 // Prepare initial state 27 // Prepare initial state
28 _zeroPoint = new Point(0, 0); 28 _zeroPoint = new Point(0, 0);
29 _zoom = _getZoom(); 29 _zoom = _getZoom();
30 // Schedule zoom check every 100ms 30 // Schedule zoom check every 100ms
(...skipping 17 matching lines...) Expand all
48 void removeListener(ZoomListener listener) { 48 void removeListener(ZoomListener listener) {
49 bool found = false; 49 bool found = false;
50 _listeners = _listeners.filter(bool _(element) => found || !(found = (elemen t == listener))); 50 _listeners = _listeners.filter(bool _(element) => found || !(found = (elemen t == listener)));
51 } 51 }
52 52
53 double _getZoom() { 53 double _getZoom() {
54 Point zoomPoint = _window.webkitConvertPointFromNodeToPage(_zoomElement, _ze roPoint); 54 Point zoomPoint = _window.webkitConvertPointFromNodeToPage(_zoomElement, _ze roPoint);
55 return zoomPoint.y / -100.0; 55 return zoomPoint.y / -100.0;
56 } 56 }
57 } 57 }
OLDNEW
« no previous file with comments | « client/samples/total/src/ValuePicker.dart ('k') | client/tests/client/samples/dartcombat/dartcombat_tests.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698