Skip to content

Commit

Permalink
make it so Touch DPad support does not need offsets.
Browse files Browse the repository at this point in the history
You can pass in offsetX and offsetY to the center of the DPad
but otherwise it will assume the center of the element that represents the DPad
  • Loading branch information
greggman committed Jun 4, 2015
1 parent add68e9 commit 1fc0c00
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions public/hft/0.x.x/scripts/misc/touch.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ define(
var padOptions = options.pads[padId];
pad.pointerId = e.pointerId;
var relPos = Input.getRelativeCoordinates(padOptions.referenceElement, e);
var x = relPos.x - padOptions.offsetX;
var y = relPos.y - padOptions.offsetY;
var x = relPos.x - (padOptions.offsetX || padOptions.referenceElement.clientWidth / 2);
var y = relPos.y - (padOptions.offsetY || padOptions.referenceElement.clientHeight / 2);
if (options.fixedCenter) {
pad.pointerStartPos.reset(0, 0);
pad.pointerPos.reset(x, y);
Expand Down Expand Up @@ -300,8 +300,8 @@ define(
if (pad.pointerId === e.pointerId) {
var padOptions = options.pads[ii];
var relPos = Input.getRelativeCoordinates(padOptions.referenceElement, e);
var x = relPos.x - padOptions.offsetX;
var y = relPos.y - padOptions.offsetY;
var x = relPos.x - (padOptions.offsetX || padOptions.referenceElement.clientWidth / 2);
var y = relPos.y - (padOptions.offsetY || padOptions.referenceElement.clientHeight / 2);
pad.pointerPos.reset(x, y);
pad.vector.copyFrom(pad.pointerPos);
pad.vector.minusEq(pad.pointerStartPos);
Expand Down

0 comments on commit 1fc0c00

Please sign in to comment.