| 1 |
<!doctype html> |
| 2 |
<html> |
| 3 |
<!-- |
| 4 |
Copyright 2013 The Closure Library Authors. All Rights Reserved. |
| 5 |
|
| 6 |
Use of this source code is governed by the Apache License, Version 2.0. |
| 7 |
See the COPYING file for details. |
| 8 |
--> |
| 9 |
<head> |
| 10 |
<title>goog.labs.style.PixelDensityMonitor</title> |
| 11 |
<script src="../base.js"></script> |
| 12 |
<script> |
| 13 |
goog.require('goog.debug.DivConsole'); |
| 14 |
goog.require('goog.events'); |
| 15 |
goog.require('goog.labs.style.PixelDensityMonitor'); |
| 16 |
goog.require('goog.labs.style.PixelDensityMonitor.Density'); |
| 17 |
goog.require('goog.log'); |
| 18 |
</script> |
| 19 |
<link rel="stylesheet" href="css/demo.css"> |
| 20 |
</head> |
| 21 |
<body> |
| 22 |
<h1>goog.labs.style.PixelDensityMonitor</h1> |
| 23 |
<div> |
| 24 |
Move between high dpi and normal screens to see density change events. |
| 25 |
</div> |
| 26 |
<fieldset class="goog-debug-panel"> |
| 27 |
<legend>Event log</legend> |
| 28 |
<div class="log" id="log"></div> |
| 29 |
</fieldset> |
| 30 |
<script> |
| 31 |
var logger = goog.log.getLogger('PixelDensityMonitor'); |
| 32 |
|
| 33 |
new goog.debug.DivConsole(goog.dom.getElement('log')).setCapturing(true); |
| 34 |
|
| 35 |
var monitor = new goog.labs.style.PixelDensityMonitor(); |
| 36 |
monitor.start(); |
| 37 |
|
| 38 |
var densityMap = goog.object.create( |
| 39 |
goog.labs.style.PixelDensityMonitor.Density.NORMAL, 'NORMAL', |
| 40 |
goog.labs.style.PixelDensityMonitor.Density.HIGH, 'HIGH'); |
| 41 |
|
| 42 |
goog.events.listen(monitor, |
| 43 |
goog.labs.style.PixelDensityMonitor.EventType.CHANGE, |
| 44 |
function() { |
| 45 |
goog.log.info(logger, 'Density change: ' + densityMap[monitor.getDensity()]); |
| 46 |
}); |
| 47 |
|
| 48 |
goog.log.info(logger, 'Starting density: ' + densityMap[monitor.getDensity()]); |
| 49 |
</script> |
| 50 |
</body> |
| 51 |
</html> |