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

Unified Diff: samples/total/client/ZoomTracker.dart

Issue 10635015: Delete proxy and total samples, which have bit-rotted. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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
« no previous file with comments | « samples/total/client/ValuePicker.dart ('k') | samples/total/client/img/123.png » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/total/client/ZoomTracker.dart
===================================================================
--- samples/total/client/ZoomTracker.dart (revision 9011)
+++ samples/total/client/ZoomTracker.dart (working copy)
@@ -1,57 +0,0 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-typedef void ZoomListener(double oldZoom, double newZoom);
-
-/**
- * This class tracks changing zoom factor in browser and notifies about this asynchroniously.
- */
-class ZoomTracker {
- List<ZoomListener> _listeners;
- Window _window;
- Point _zeroPoint;
- double _zoom;
- Element _zoomElement;
-
- ZoomTracker(this._window) {
- _listeners = new List<ZoomListener>();
- // Append element with known CSS location
- _zoomElement = new Element.tag("div");
- _zoomElement.id = "zoomTracker";
- _zoomElement.style.setProperty("position", "absolute");
- _zoomElement.style.setProperty("top", "-100px");
- _zoomElement.style.setProperty("height", "0px");
- _zoomElement.style.setProperty("visibility", "hidden");
- document.body.nodes.add(_zoomElement);
- // Prepare initial state
- _zeroPoint = new Point(0, 0);
- _zoom = _getZoom();
- // Schedule zoom check every 100ms
- _window.setInterval(() {
- double newZoom = _getZoom();
- if (newZoom != _zoom) {
- _listeners.forEach((ZoomListener listener) {
- listener(_zoom, newZoom);
- });
- _zoom = newZoom;
- }
- }, 100);
- }
-
- void addListener(ZoomListener listener) {
- if (_listeners.isEmpty() || _listeners.indexOf(listener, 0) == -1) {
- _listeners.add(listener);
- }
- }
-
- void removeListener(ZoomListener listener) {
- bool found = false;
- _listeners = _listeners.filter(bool _(element) => found || !(found = (element == listener)));
- }
-
- double _getZoom() {
- Point zoomPoint = _window.webkitConvertPointFromNodeToPage(_zoomElement, _zeroPoint);
- return zoomPoint.y / -100.0;
- }
-}
« no previous file with comments | « samples/total/client/ValuePicker.dart ('k') | samples/total/client/img/123.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698