git @ Cat's Eye Technologies yoob.js / master eg / full-screen-detector.html
master

Tree @master (Download .tar.gz)

full-screen-detector.html @masterraw · history · blame

<!DOCTYPE html>
<head>
  <meta charset="utf-8">
  <title>yoob.FullScreenDetector Demo</title>
  <style>
#canvas {
  border: 1px solid blue;
}
#container {
  text-align: left;
}
  </style>
</head>
<body>

<h1 id="h1">yoob.FullScreenDetector Demo</h1>

<div id="container">
  <canvas id="canvas" width="600" height="400">
  Your browser doesn't support displaying an HTML5 canvas.
  </canvas>
</div>

</body>
<script src="../src/yoob/full-screen-detector.js"></script>
<script>
  var h1 = document.getElementById('h1');
  var container = document.getElementById('container');
  var canvas = document.getElementById('canvas');

  var ctx = canvas.getContext('2d');
  ctx.lineWidth = 5;
  ctx.strokeStyle = "black";
  ctx.beginPath();
  ctx.moveTo(0, 0);
  ctx.lineTo(canvas.width, canvas.height);
  ctx.moveTo(0, canvas.height);
  ctx.lineTo(canvas.width, 0);
  ctx.stroke();

  var savedBodyMargin;
  new yoob.FullScreenDetector({
      onchange: function(fullScreen) {
          if (fullScreen) {
              canvas.style.width = screen.width + "px";
              // attempting to use full screen height will cause scrollbars
              canvas.style.height = (screen.height - 5) + "px";
              canvas.style.border = "none";
              savedBodyMargin = document.body.style.margin;
              document.body.style.margin = "0";
              container.style.textAlign = 'center';
              h1.style.display = "none";
          } else {
              canvas.style.width = "600px";
              canvas.style.height = "400px";
              canvas.style.border = "1px solid blue";
              document.body.style.margin = savedBodyMargin;
              container.style.textAlign = 'left';
              h1.style.display = "block";
          }
      }
  });
</script>