Skip to content

Commit

Permalink
Add fallback value for devicePixelRatio
Browse files Browse the repository at this point in the history
In IE 10 for example, devicePixelRatio doesn't exist which caused the
code to fail by setting the thresholds to zero.
  • Loading branch information
samhed committed May 12, 2016
1 parent 057cfc7 commit f52105b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions include/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion include/rfb.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit f52105b

Please sign in to comment.