mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-29 00:26:10 +03:00
isPrimary handling
This commit is contained in:
parent
e7bc65c0af
commit
c22e624a3d
@ -2069,7 +2069,7 @@
|
|||||||
* @inner
|
* @inner
|
||||||
*/
|
*/
|
||||||
function onLoseCapture( tracker, event ) {
|
function onLoseCapture( tracker, event ) {
|
||||||
$.console.log('losecapture ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
//$.console.log('losecapture ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
||||||
event = $.getEvent( event );
|
event = $.getEvent( event );
|
||||||
|
|
||||||
var gPoint = {
|
var gPoint = {
|
||||||
@ -2518,7 +2518,8 @@
|
|||||||
gPoint = {
|
gPoint = {
|
||||||
id: event.changedTouches[ i ].identifier,
|
id: event.changedTouches[ i ].identifier,
|
||||||
type: 'touch',
|
type: 'touch',
|
||||||
// isPrimary not set - let the updatePointers functions determine it
|
// Simulate isPrimary
|
||||||
|
isPrimary: pointsList.getLength() === 0,
|
||||||
currentPos: getMouseAbsolute( event.changedTouches[ i ] ),
|
currentPos: getMouseAbsolute( event.changedTouches[ i ] ),
|
||||||
currentTime: time
|
currentTime: time
|
||||||
};
|
};
|
||||||
@ -2566,7 +2567,6 @@
|
|||||||
gPoint = {
|
gPoint = {
|
||||||
id: event.changedTouches[ i ].identifier,
|
id: event.changedTouches[ i ].identifier,
|
||||||
type: 'touch',
|
type: 'touch',
|
||||||
// isPrimary not set - let the updatePointers functions determine it
|
|
||||||
currentPos: getMouseAbsolute( event.changedTouches[ i ] ),
|
currentPos: getMouseAbsolute( event.changedTouches[ i ] ),
|
||||||
currentTime: time
|
currentTime: time
|
||||||
};
|
};
|
||||||
@ -2612,7 +2612,6 @@
|
|||||||
gPoint = {
|
gPoint = {
|
||||||
id: event.changedTouches[ i ].identifier,
|
id: event.changedTouches[ i ].identifier,
|
||||||
type: 'touch',
|
type: 'touch',
|
||||||
// isPrimary not set - let the updatePointers functions determine it
|
|
||||||
currentPos: getMouseAbsolute( event.changedTouches[ i ] ),
|
currentPos: getMouseAbsolute( event.changedTouches[ i ] ),
|
||||||
currentTime: time
|
currentTime: time
|
||||||
};
|
};
|
||||||
@ -2705,8 +2704,6 @@
|
|||||||
|
|
||||||
if ( event.target === tracker.element ) {
|
if ( event.target === tracker.element ) {
|
||||||
//$.console.log('gotpointercapture ' + (tracker.userData ? tracker.userData.toString() : ''));
|
//$.console.log('gotpointercapture ' + (tracker.userData ? tracker.userData.toString() : ''));
|
||||||
////$.cancelEvent( event ); not cancelable!
|
|
||||||
//$.stopEvent( event );
|
|
||||||
updatePointerCaptured( tracker, {
|
updatePointerCaptured( tracker, {
|
||||||
id: event.pointerId,
|
id: event.pointerId,
|
||||||
type: getPointerType( event )
|
type: getPointerType( event )
|
||||||
@ -2736,8 +2733,6 @@
|
|||||||
|
|
||||||
if ( event.target === tracker.element ) {
|
if ( event.target === tracker.element ) {
|
||||||
//$.console.log('lostpointercapture ' + (tracker.userData ? tracker.userData.toString() : ''));
|
//$.console.log('lostpointercapture ' + (tracker.userData ? tracker.userData.toString() : ''));
|
||||||
////$.cancelEvent( event ); not cancelable!
|
|
||||||
//$.stopEvent( event );
|
|
||||||
updatePointerCaptured( tracker, {
|
updatePointerCaptured( tracker, {
|
||||||
id: event.pointerId,
|
id: event.pointerId,
|
||||||
type: getPointerType( event )
|
type: getPointerType( event )
|
||||||
@ -2923,7 +2918,6 @@
|
|||||||
|
|
||||||
//$.console.log('onPointerDown ' + (tracker.userData ? tracker.userData.toString() : ''));
|
//$.console.log('onPointerDown ' + (tracker.userData ? tracker.userData.toString() : ''));
|
||||||
// $.console.log('onPointerDown ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + event.target.tagName);
|
// $.console.log('onPointerDown ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + event.target.tagName);
|
||||||
// event.target.style.background = '#F0F';
|
|
||||||
|
|
||||||
// Most browsers implicitly capture touch pointer events
|
// Most browsers implicitly capture touch pointer events
|
||||||
// Note no IE versions have element.hasPointerCapture() so no implicit
|
// Note no IE versions have element.hasPointerCapture() so no implicit
|
||||||
@ -2963,17 +2957,12 @@
|
|||||||
$.stopEvent( event );
|
$.stopEvent( event );
|
||||||
}
|
}
|
||||||
if ( eventInfo.shouldCapture && !implicitlyCaptured ) {
|
if ( eventInfo.shouldCapture && !implicitlyCaptured ) {
|
||||||
//$.stopEvent( event );
|
|
||||||
//$.console.log('pointerdown calling capturePointer() ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
//$.console.log('pointerdown calling capturePointer() ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
||||||
capturePointer( tracker, gPoint );
|
capturePointer( tracker, gPoint );
|
||||||
} else if ( !eventInfo.shouldCapture && implicitlyCaptured ) {
|
} else if ( !eventInfo.shouldCapture && implicitlyCaptured ) {
|
||||||
//$.stopEvent( event );
|
|
||||||
//$.console.log('pointerdown calling releasePointer() ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
//$.console.log('pointerdown calling releasePointer() ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
||||||
releasePointer( tracker, gPoint ); //TODO should we do this? Investigate when implementing bubble handling
|
releasePointer( tracker, gPoint ); //TODO should we do this? Investigate when implementing bubble handling
|
||||||
}
|
}
|
||||||
// else if ( eventInfo.shouldCapture && implicitlyCaptured ) {
|
|
||||||
// //$.stopEvent( event );
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3111,7 +3100,7 @@
|
|||||||
* @inner
|
* @inner
|
||||||
*/
|
*/
|
||||||
function onPointerCancel( tracker, event ) {
|
function onPointerCancel( tracker, event ) {
|
||||||
//$.console.log('pointercancel ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.isPrimary ? 'isPrimary' : ''));
|
//$.console.log('pointercancel ' + (tracker.userData ? tracker.userData.toString() : ''));
|
||||||
|
|
||||||
var gPoint = {
|
var gPoint = {
|
||||||
id: event.pointerId,
|
id: event.pointerId,
|
||||||
@ -3150,16 +3139,6 @@
|
|||||||
* @returns {Number} Number of gesture points in pointsList.
|
* @returns {Number} Number of gesture points in pointsList.
|
||||||
*/
|
*/
|
||||||
function startTrackingPointer( pointsList, gPoint ) {
|
function startTrackingPointer( pointsList, gPoint ) {
|
||||||
|
|
||||||
// If isPrimary is not known for the pointer then set it according to our rules:
|
|
||||||
// true if the first pointer in the gesture, otherwise false
|
|
||||||
if ( !Object.prototype.hasOwnProperty.call( gPoint, 'isPrimary' ) ) {
|
|
||||||
if ( pointsList.getLength() === 0 ) {
|
|
||||||
gPoint.isPrimary = true;
|
|
||||||
} else {
|
|
||||||
gPoint.isPrimary = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
gPoint.speed = 0;
|
gPoint.speed = 0;
|
||||||
gPoint.direction = 0;
|
gPoint.direction = 0;
|
||||||
gPoint.contactPos = gPoint.currentPos;
|
gPoint.contactPos = gPoint.currentPos;
|
||||||
@ -3195,18 +3174,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
listLength = pointsList.removeById( gPoint.id );
|
listLength = pointsList.removeById( gPoint.id );
|
||||||
|
|
||||||
//TODO Browsers don't re-assign primary pointers so this is probably incorrect
|
|
||||||
// // If isPrimary is not known for the pointer and we just removed the primary pointer from the list then we need to set another pointer as primary
|
|
||||||
// if ( !Object.prototype.hasOwnProperty.call( gPoint, 'isPrimary' ) ) {
|
|
||||||
// primaryPoint = pointsList.getPrimary();
|
|
||||||
// if ( !primaryPoint ) {
|
|
||||||
// primaryPoint = pointsList.getByIndex( 0 );
|
|
||||||
// if ( primaryPoint ) {
|
|
||||||
// primaryPoint.isPrimary = true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
} else {
|
} else {
|
||||||
listLength = pointsList.getLength();
|
listLength = pointsList.getLength();
|
||||||
}
|
}
|
||||||
@ -4047,9 +4014,6 @@
|
|||||||
|
|
||||||
if ( updateGPoint ) {
|
if ( updateGPoint ) {
|
||||||
// Already tracking the pointer...update it
|
// Already tracking the pointer...update it
|
||||||
if ( Object.prototype.hasOwnProperty.call( gPoint, 'isPrimary' ) ) {
|
|
||||||
updateGPoint.isPrimary = gPoint.isPrimary;
|
|
||||||
}
|
|
||||||
updateGPoint.lastPos = updateGPoint.currentPos;
|
updateGPoint.lastPos = updateGPoint.currentPos;
|
||||||
updateGPoint.lastTime = updateGPoint.currentTime;
|
updateGPoint.lastTime = updateGPoint.currentTime;
|
||||||
updateGPoint.currentPos = gPoint.currentPos;
|
updateGPoint.currentPos = gPoint.currentPos;
|
||||||
@ -4198,10 +4162,6 @@
|
|||||||
if ( updateGPoint ) {
|
if ( updateGPoint ) {
|
||||||
stopTrackingPointer( tracker, pointsList, updateGPoint );
|
stopTrackingPointer( tracker, pointsList, updateGPoint );
|
||||||
}
|
}
|
||||||
//else {
|
|
||||||
// // should never get here?
|
|
||||||
// $.console.warn('updatePointerCancel(): pointercancel on untracked gPoint');
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user