Merge pull request #501 from immense/jaredg-scroll-touch-refinements

Scroll touch refinement.
This commit is contained in:
Jared Goodwin 2022-08-02 04:28:05 -07:00 committed by GitHub
commit db11194254
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 3 deletions

View File

@ -286,8 +286,17 @@ export function ApplyInputHandlers() {
if (e.touches.length == 2) {
let touchMove1 = lastScrollTouchY1 - e.touches[0].pageY;
let touchMove2 = lastScrollTouchY2 - e.touches[1].pageY;
if (!isPinchZooming && (touchMove1 * touchMove2 > 0 || isScrolling)) {
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);
}
isScrolling = true;
if (Date.now() - lastScrollTime < 100) {
return;

File diff suppressed because one or more lines are too long

View File

@ -357,8 +357,19 @@ export function ApplyInputHandlers() {
let touchMove1 = lastScrollTouchY1 - e.touches[0].pageY;
let touchMove2 = lastScrollTouchY2 - e.touches[1].pageY;
if (!isPinchZooming && (touchMove1 * touchMove2 > 0 || isScrolling)) {
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);
}
isScrolling = true;
if (Date.now() - lastScrollTime < 100) {
return;