浏览代码

Add fallback value for devicePixelRatio

In IE 10 for example, devicePixelRatio doesn't exist which caused the
code to fail by setting the thresholds to zero.
samhed 9 年之前
父节点
当前提交
f52105bc88
共有 2 个文件被更改,包括 4 次插入3 次删除
  1. 3 2
      include/input.js
  2. 1 1
      include/rfb.js

+ 3 - 2
include/input.js

@@ -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;
                         }
                     }

+ 1 - 1
include/rfb.js

@@ -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)) {