Skip to content

Commit

Permalink
Fix rotation calculation to prevent 90 degree jump
Browse files Browse the repository at this point in the history
Based on hammerjs#982
  • Loading branch information
squadette committed Aug 24, 2019
1 parent a0eb000 commit 5c53476
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- Fix rotation calculation to prevent 90 degree jump.

Based on https://github.com/hammerjs/hammer.js/pull/982

### 2.1.0pre0

No functional changes, prepare baseline for future changes.
Expand Down
2 changes: 1 addition & 1 deletion hammer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1679,7 +1679,7 @@ function getScale(start, end) {
* @return {Number} rotation
*/
function getRotation(start, end) {
return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
return getAngle(end[1], end[0], PROPS_CLIENT_XY) - getAngle(start[1], start[0], PROPS_CLIENT_XY);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion hammer.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/inputjs/get-rotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import { PROPS_CLIENT_XY } from './input-consts';
* @return {Number} rotation
*/
export default function getRotation(start, end) {
return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
return getAngle(end[1], end[0], PROPS_CLIENT_XY) - getAngle(start[1], start[0], PROPS_CLIENT_XY);
}

0 comments on commit 5c53476

Please sign in to comment.