Skip to content

Commit

Permalink
fix: touch coordinates with scrolling
Browse files Browse the repository at this point in the history
fix #135
  • Loading branch information
drauggres committed Aug 31, 2021
1 parent 7e13d62 commit 4247f2a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/app/touchHandler/TouchHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,12 @@ export abstract class TouchHandler {
if (typeof action === 'undefined' || !screenInfo) {
return null;
}
const htmlTag = document.getElementsByTagName('html')[0] as HTMLElement;
const { width, height } = screenInfo.videoSize;
const target: HTMLElement = e.target as HTMLElement;
const { scrollTop, scrollLeft } = htmlTag;
const rect = target.getBoundingClientRect();
let { clientWidth, clientHeight } = target;
let touchX = e.clientX - target.offsetLeft + scrollLeft;
let touchY = e.clientY - target.offsetTop + scrollTop;
let touchX = e.clientX - rect.left;
let touchY = e.clientY - rect.top;
let invalid = false;
if (touchX < 0 || touchX > clientWidth || touchY < 0 || touchY > clientHeight) {
invalid = true;
Expand Down

0 comments on commit 4247f2a

Please sign in to comment.