URI:
       fix button binding happening more than ones (fixes #5) - webgbcam - [fork] gameboy webcam
  HTML git clone git://src.adamsgaard.dk/webgbcam
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 4a17cd273a37de89be94693fdee1eaa84f5e752d
   DIR parent 27a712f55eeacc65ffc232ea1641c733b734440b
  HTML Author: Erin Pinheiro <hello@mynameiser.in>
       Date:   Sat, 24 Oct 2020 22:42:11 -0300
       
       fix button binding happening more than ones (fixes #5)
       
       Diffstat:
         M .gitignore                          |       5 +++--
         M app.js                              |      38 +++++++++++++++++--------------
       
       2 files changed, 24 insertions(+), 19 deletions(-)
       ---
   DIR diff --git a/.gitignore b/.gitignore
       @@ -1 +1,2 @@
       -*.aseprite
       -\ No newline at end of file
       +*.aseprite
       +todo.txt
       +\ No newline at end of file
   DIR diff --git a/app.js b/app.js
       @@ -515,7 +515,7 @@ document.addEventListener('DOMContentLoaded', function (event) {
        
        function restartCamera() {
                setTimeout(function() {
       -                initCameraUI();
       +                initAppScaling();
                        initCameraDrawing();
                }, 300);
        }
       @@ -524,22 +524,7 @@ window.onorientationchange = restartCamera;
        window.onresize = restartCamera;
        
        function initCameraUI() {
       -        // figure out max integer render scale for window
       -        if(window.innerWidth >= window.innerHeight) {
       -                // horizontal
       -                appScale = Math.floor(window.innerHeight / renderHeight);
       -        } else {
       -                // vertical
       -                appScale = Math.floor(window.innerWidth / renderWidth);
       -        }
       -        cameraDiv.style.width = appScale * renderWidth + "px";
       -        cameraDiv.style.height = appScale * renderHeight + "px";
       -
       -        // canvas sizes
       -        cameraView.width = cameraVars.width;
       -        cameraView.height = cameraVars.height;
       -        appView.width = renderWidth;
       -        appView.height = renderHeight;
       +        initAppScaling();
        
                // handle canvas app clicks
                appView.addEventListener('click', function(e) {
       @@ -599,6 +584,25 @@ function initCameraUI() {
                }, false);
        }
        
       +function initAppScaling() {
       +        // figure out max integer render scale for window
       +        if(window.innerWidth >= window.innerHeight) {
       +                // horizontal
       +                appScale = Math.floor(window.innerHeight / renderHeight);
       +        } else {
       +                // vertical
       +                appScale = Math.floor(window.innerWidth / renderWidth);
       +        }
       +        cameraDiv.style.width = appScale * renderWidth + "px";
       +        cameraDiv.style.height = appScale * renderHeight + "px";
       +
       +        // canvas sizes
       +        cameraView.width = cameraVars.width;
       +        cameraView.height = cameraVars.height;
       +        appView.width = renderWidth;
       +        appView.height = renderHeight;
       +}
       +
        // https://github.com/webrtc/samples/blob/gh-pages/src/content/devices/input-output/js/main.js
        function initCameraStream() {
                // stop any active streams in the window