]> git.proxmox.com Git - mirror_novnc.git/commitdiff
Add fallback value for devicePixelRatio
authorsamhed <samuel@cendio.se>
Thu, 12 May 2016 14:43:19 +0000 (16:43 +0200)
committersamhed <samuel@cendio.se>
Thu, 12 May 2016 14:43:19 +0000 (16:43 +0200)
In IE 10 for example, devicePixelRatio doesn't exist which caused the
code to fail by setting the thresholds to zero.

include/input.js
include/rfb.js

index 5d9e209e650d611c6ffe8c0d2d9f101b4a70168c..fa6ba44a14ab8f8802a6658030a84997a24560fc 100644 (file)
@@ -212,7 +212,7 @@ var Keyboard, Mouse;
                 // Touch device
 
                 // When two touches occur within 500 ms of each other and are
-                // closer than 20 pixels together a double click is triggered.
+                // close enough together a double click is triggered.
                 if (down == 1) {
                     if (this._doubleClickTimer === null) {
                         this._lastTouchPos = pos;
@@ -229,7 +229,8 @@ var Keyboard, Mouse;
 
                         // The goal is to trigger on a certain physical width, the
                         // devicePixelRatio brings us a bit closer but is not optimal.
-                        if (d < 20 * window.devicePixelRatio) {
+                        var threshold = 20 * (window.devicePixelRatio || 1);
+                        if (d < threshold) {
                             pos = this._lastTouchPos;
                         }
                     }
index 3e9344bbcf72880cfff48fcd28e720d0ef51f492..48fa5a8c5450e4330fc8c4eeb7b873ab9cbe3485 100644 (file)
@@ -617,7 +617,7 @@ var RFB;
 
                 // The goal is to trigger on a certain physical width, the
                 // devicePixelRatio brings us a bit closer but is not optimal.
-                var dragThreshold = 10 * window.devicePixelRatio;
+                var dragThreshold = 10 * (window.devicePixelRatio || 1);
 
                 if (this._viewportHasMoved || (Math.abs(deltaX) > dragThreshold ||
                                                Math.abs(deltaY) > dragThreshold)) {