fix: contacts points on touch devices

Swiping fast multiple times makes contacts points in mousetracker to be out of sync for touch event

Fixes #2117
This commit is contained in:
Ronny Mikalsen 2022-02-22 14:24:10 +01:00
parent 2b6c8dd622
commit 47cc04ff53
2 changed files with 15 additions and 9 deletions

View File

@ -1400,11 +1400,20 @@
* @function * @function
*/ */
removeContact: function() { removeContact: function() {
--this.contacts; if (
(this.type === "mouse" ||
this.type === "pen" ||
this.type === "touch") &&
this.contacts > 0
) {
--this.contacts;
if (this.contacts < 0) { if (this.contacts < 0) {
$.console.warn('GesturePointList.removeContact() Implausible contacts value'); $.console.warn(
this.contacts = 0; "GesturePointList.removeContact() Implausible contacts value"
);
this.contacts = 0;
}
} }
} }
}; };
@ -2823,10 +2832,7 @@
// If child element relinquishes capture to a parent we may get here // If child element relinquishes capture to a parent we may get here
// from a pointerleave event while a pointerup event will never be received. // from a pointerleave event while a pointerup event will never be received.
// In that case, we'll clean up the contact count // In that case, we'll clean up the contact count
if ( (pointsList.type === 'mouse' || pointsList.type === 'pen') && pointsList.removeContact();
pointsList.contacts > 0 ) {
pointsList.removeContact();
}
listLength = pointsList.removeById( gPoint.id ); listLength = pointsList.removeById( gPoint.id );
} else { } else {

View File

@ -25,7 +25,7 @@
// debugMode: true, // debugMode: true,
id: "contentDiv", id: "contentDiv",
prefixUrl: "../../build/openseadragon/images/", prefixUrl: "../../build/openseadragon/images/",
tileSources: "http://wellcomelibrary.org/iiif-img/b11768265-0/a6801943-b8b4-4674-908c-7d5b27e70569/info.json", tileSources: "https://iiif.wellcomecollection.org/image/V0021191/info.json",
showNavigator:true showNavigator:true
}); });