Fix mouse move.

This commit is contained in:
Jared Goodwin 2022-08-01 18:41:53 -07:00
parent 3d15470d3d
commit 377c32a33b
3 changed files with 7 additions and 3 deletions

View File

@ -286,11 +286,13 @@ export function ApplyInputHandlers() {
if (e.touches.length == 2) {
let touchMove1 = lastScrollTouchY1 - e.touches[0].pageY;
let touchMove2 = lastScrollTouchY2 - e.touches[1].pageY;
if (!isPinchZooming && (isScrolling || touchMove1 * touchMove2 > 10)) {
if (!isPinchZooming && (isScrolling || touchMove1 * touchMove2 > 0)) {
// Both touch points are moving in the same direction. We're doing a scroll.
if (!isScrolling) {
// If this is the start of scrolling, move the mouse to our touch point so
// the scroll wheel action will target the intended element on screen.
var screenViewerLeft = viewer.getBoundingClientRect().left;
var screenViewerTop = viewer.getBoundingClientRect().top;
var pagePercentX = (e.touches[0].pageX - screenViewerLeft) / viewer.clientWidth;
var pagePercentY = (e.touches[0].pageY - screenViewerTop) / viewer.clientHeight;
ViewerApp.MessageSender.SendMouseMove(pagePercentX, pagePercentY);

File diff suppressed because one or more lines are too long

View File

@ -357,12 +357,14 @@ export function ApplyInputHandlers() {
let touchMove1 = lastScrollTouchY1 - e.touches[0].pageY;
let touchMove2 = lastScrollTouchY2 - e.touches[1].pageY;
if (!isPinchZooming && (isScrolling || touchMove1 * touchMove2 > 10)) {
if (!isPinchZooming && (isScrolling || touchMove1 * touchMove2 > 0)) {
// Both touch points are moving in the same direction. We're doing a scroll.
if (!isScrolling) {
// If this is the start of scrolling, move the mouse to our touch point so
// the scroll wheel action will target the intended element on screen.
var screenViewerLeft = viewer.getBoundingClientRect().left;
var screenViewerTop = viewer.getBoundingClientRect().top;
var pagePercentX = (e.touches[0].pageX - screenViewerLeft) / viewer.clientWidth;
var pagePercentY = (e.touches[0].pageY - screenViewerTop) / viewer.clientHeight;
ViewerApp.MessageSender.SendMouseMove(pagePercentX, pagePercentY);