mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 05:06:09 +03:00
Fixed test "Events: Viewer: preventDefaultAction in dblClickHandler". Fixes #1372
This commit is contained in:
parent
16ab337146
commit
b0447979f3
@ -41,6 +41,7 @@ OPENSEADRAGON CHANGELOG
|
|||||||
* Added setImageFormatsSupported function (#1954 @pandaxtc)
|
* Added setImageFormatsSupported function (#1954 @pandaxtc)
|
||||||
* Added dragToPan to the GestureSettings class, implemented in Viewer (#1956 @msalsbery)
|
* Added dragToPan to the GestureSettings class, implemented in Viewer (#1956 @msalsbery)
|
||||||
* Added preventDefault option to MouseTracker handlers: scrollHandler, keyDownHandler, keyUpHandler, keyHandler (#1957 @msalsbery)
|
* Added preventDefault option to MouseTracker handlers: scrollHandler, keyDownHandler, keyUpHandler, keyHandler (#1957 @msalsbery)
|
||||||
|
* Fixed test "Events: Viewer: preventDefaultAction in dblClickHandler". Fixes #1372 (#1959 @msalsbery)
|
||||||
|
|
||||||
2.4.2:
|
2.4.2:
|
||||||
|
|
||||||
|
@ -835,20 +835,67 @@
|
|||||||
var done = assert.async();
|
var done = assert.async();
|
||||||
var tracker = viewer.innerTracker;
|
var tracker = viewer.innerTracker;
|
||||||
var epsilon = 0.0000001;
|
var epsilon = 0.0000001;
|
||||||
|
var $canvas = $( viewer.element ).find( '.openseadragon-canvas' ).not( '.navigator .openseadragon-canvas' ),
|
||||||
|
simEvent = {},
|
||||||
|
offset = $canvas.offset();
|
||||||
|
|
||||||
|
var simulateEnter = function (x, y) {
|
||||||
|
simEvent.clientX = offset.left + x;
|
||||||
|
simEvent.clientY = offset.top + y;
|
||||||
|
$canvas.simulate( 'mouseenter', simEvent );
|
||||||
|
};
|
||||||
|
|
||||||
|
var simulateLeave = function (x, y) {
|
||||||
|
simEvent.clientX = offset.left + x;
|
||||||
|
simEvent.clientY = offset.top + y;
|
||||||
|
simEvent.relatedTarget = document.body;
|
||||||
|
$canvas.simulate( 'mouseleave', simEvent );
|
||||||
|
};
|
||||||
|
|
||||||
|
var simulateDown = function (x, y) {
|
||||||
|
simEvent.button = 0;
|
||||||
|
simEvent.clientX = offset.left + x;
|
||||||
|
simEvent.clientY = offset.top + y;
|
||||||
|
$canvas.simulate( 'mousedown', simEvent );
|
||||||
|
};
|
||||||
|
|
||||||
|
var simulateUp = function (x, y) {
|
||||||
|
simEvent.button = 0;
|
||||||
|
simEvent.clientX = offset.left + x;
|
||||||
|
simEvent.clientY = offset.top + y;
|
||||||
|
$canvas.simulate( 'mouseup', simEvent );
|
||||||
|
};
|
||||||
|
|
||||||
|
// function simulateDblTap() {
|
||||||
|
// var touches = [];
|
||||||
|
// TouchUtil.reset();
|
||||||
|
|
||||||
|
// touches.push(TouchUtil.start([0,0]));
|
||||||
|
// TouchUtil.end( touches[0] );
|
||||||
|
// touches.push(TouchUtil.start([0,0]));
|
||||||
|
// TouchUtil.end( touches[1] );
|
||||||
|
// }
|
||||||
function simulateDblTap() {
|
function simulateDblTap() {
|
||||||
var touches = [];
|
simulateEnter(2, 2);
|
||||||
TouchUtil.reset();
|
simulateDown(2, 2);
|
||||||
|
simulateUp(2, 2);
|
||||||
touches.push(TouchUtil.start([0,0]));
|
simulateDown(2, 2);
|
||||||
TouchUtil.end( touches[0] );
|
simulateUp(2, 2);
|
||||||
touches.push(TouchUtil.start([0,0]));
|
simulateLeave(-1, -1);
|
||||||
TouchUtil.end( touches[1] );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var onOpen = function() {
|
var onOpen = function() {
|
||||||
|
var origClickSetting,
|
||||||
|
origDblClickSetting;
|
||||||
|
|
||||||
viewer.removeHandler('open', onOpen);
|
viewer.removeHandler('open', onOpen);
|
||||||
|
|
||||||
|
origClickSetting = viewer.gestureSettingsMouse.clickToZoom;
|
||||||
|
origDblClickSetting = viewer.gestureSettingsMouse.dblClickToZoom;
|
||||||
|
|
||||||
|
viewer.gestureSettingsMouse.clickToZoom = false;
|
||||||
|
viewer.gestureSettingsMouse.dblClickToZoom = true;
|
||||||
|
|
||||||
var originalZoom = viewer.viewport.getZoom();
|
var originalZoom = viewer.viewport.getZoom();
|
||||||
|
|
||||||
var onCanvasDblClick = function (event) {
|
var onCanvasDblClick = function (event) {
|
||||||
@ -857,7 +904,6 @@
|
|||||||
|
|
||||||
viewer.addHandler('canvas-double-click', onCanvasDblClick);
|
viewer.addHandler('canvas-double-click', onCanvasDblClick);
|
||||||
|
|
||||||
TouchUtil.initTracker(tracker);
|
|
||||||
simulateDblTap();
|
simulateDblTap();
|
||||||
|
|
||||||
var zoom = viewer.viewport.getZoom();
|
var zoom = viewer.viewport.getZoom();
|
||||||
@ -875,7 +921,9 @@
|
|||||||
"Zoom on double tap should not be prevented");
|
"Zoom on double tap should not be prevented");
|
||||||
|
|
||||||
|
|
||||||
TouchUtil.resetTracker(tracker);
|
viewer.gestureSettingsMouse.clickToZoom = origClickSetting;
|
||||||
|
viewer.gestureSettingsMouse.dblClickToZoom = origDblClickSetting;
|
||||||
|
|
||||||
viewer.close();
|
viewer.close();
|
||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user