Compare commits

..

23 Commits

Author SHA1 Message Date
Ian Gilman
69c4b31853 Changelog tweak 2022-11-16 14:26:18 -08:00
Ian Gilman
89a69ee1e0 Changelog for #2225 2022-11-16 14:21:51 -08:00
Ian Gilman
5bba14a763
Merge pull request #2225 from HamzaTatheer/master
One touch zoom in & out function #2077
2022-11-16 14:16:13 -08:00
Hamza Tatheer
7c44dc64bc Update viewer.js 2022-11-16 15:48:45 +05:00
Hamza Tatheer
6540a57aa9 pr changes 2022-11-12 16:32:45 +05:00
Hamza Tatheer
cb2fbe9b50 pr changes latest 2022-11-06 18:23:12 +05:00
Hamza Tatheer
fccab2da56 pr fixes 2022-11-03 23:55:35 +05:00
Hamza Tatheer
e4d9dcdd03 Triple Click Bug Fix 2022-10-30 01:27:56 +05:00
Hamza Tatheer
3ebc03ab3a demo page fix 2022-10-29 21:59:29 +05:00
Hamza Tatheer
05b596ce32 space removed 2022-10-29 21:47:37 +05:00
Hamza Tatheer
ca88de8e7f double click drag same position constraint removed 2022-10-29 21:46:12 +05:00
Hamza Tatheer
d44fc85582 pr changes 2022-10-29 21:22:25 +05:00
Hamza Tatheer
a0ac8666e0 Merge branch 'master' of https://github.com/HamzaTatheer/openseadragon 2022-10-29 20:18:23 +05:00
Hamza Tatheer
af3801367a
Merge branch 'openseadragon:master' into master 2022-10-26 11:03:28 +05:00
Hamza Tatheer
89ab847ef6 bug fix 2022-10-24 23:17:03 +05:00
Hamza Tatheer
2f28970e32 zoom infinite 2022-10-24 11:08:37 +05:00
Hamza Tatheer
e12a626efb hide toolbar 2022-10-23 23:51:27 +05:00
Hamza Tatheer
2f2285711d Update viewer.js 2022-10-23 01:30:16 +05:00
Hamza Tatheer
9a4b802286 Update index.html 2022-10-22 21:10:01 +05:00
Hamza Tatheer
8336e8336b test 2022-10-22 21:04:58 +05:00
Hamza Tatheer
3a0bb0cd58 orignal Config 2022-10-22 15:50:18 +05:00
Hamza Tatheer
41a07b2250 zoom equation updated 2022-10-22 15:47:12 +05:00
Hamza Tatheer
cd9c5032f8 functionality test 2022-10-22 12:15:28 +05:00
6 changed files with 122 additions and 7143 deletions

View File

@ -5,6 +5,7 @@ OPENSEADRAGON CHANGELOG
* NEW BEHAVIOR: Setting the viewport rotation now animates by default (pass false for the new immediately parameter to disable) (#2136 @jonasengelmann) * NEW BEHAVIOR: Setting the viewport rotation now animates by default (pass false for the new immediately parameter to disable) (#2136 @jonasengelmann)
* DEPRECATION: Don't access the viewport's degrees property directly anymore; instead use setRotation and getRotation (#2136 @jonasengelmann) * DEPRECATION: Don't access the viewport's degrees property directly anymore; instead use setRotation and getRotation (#2136 @jonasengelmann)
* New gesture: Double-click and drag to zoom (on by default for touch) (#2225 @HamzaTatheer)
* Improved the constraints that keep the image in the viewer, specifically when zoomed out a lot (#2160 @joedf) * Improved the constraints that keep the image in the viewer, specifically when zoomed out a lot (#2160 @joedf)
* You can now provide an element for the navigator (as an alternative to an ID) (#1303 @cameronbaney, #2166 #2175 @joedf) * You can now provide an element for the navigator (as an alternative to an ID) (#1303 @cameronbaney, #2166 #2175 @joedf)
* Now supporting IIIF "id" and "identifier" in addition to "@id" (#2173 @ahankinson) * Now supporting IIIF "id" and "identifier" in addition to "@id" (#2173 @ahankinson)

7126
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -47,4 +47,4 @@
"test": "grunt test", "test": "grunt test",
"prepare": "grunt build" "prepare": "grunt build"
} }
} }

View File

@ -74,6 +74,7 @@ $.ControlAnchor = {
* @param {Element} container - the element to control will be anchored too. * @param {Element} container - the element to control will be anchored too.
*/ */
$.Control = function ( element, options, container ) { $.Control = function ( element, options, container ) {
var parent = element.parentNode; var parent = element.parentNode;
if (typeof options === 'number') if (typeof options === 'number')
{ {
@ -150,6 +151,7 @@ $.Control = function ( element, options, container ) {
} else { } else {
parent.appendChild( this.wrapper ); parent.appendChild( this.wrapper );
} }
}; };
/** @lends OpenSeadragon.Control.prototype */ /** @lends OpenSeadragon.Control.prototype */

View File

@ -341,6 +341,9 @@
* @property {Boolean} [gestureSettingsMouse.clickToZoom=true] - Zoom on click gesture * @property {Boolean} [gestureSettingsMouse.clickToZoom=true] - Zoom on click gesture
* @property {Boolean} [gestureSettingsMouse.dblClickToZoom=false] - Zoom on double-click gesture. Note: If set to true * @property {Boolean} [gestureSettingsMouse.dblClickToZoom=false] - Zoom on double-click gesture. Note: If set to true
* then clickToZoom should be set to false to prevent multiple zooms. * then clickToZoom should be set to false to prevent multiple zooms.
* @property {Boolean} [gestureSettingsMouse.dblClickDragToZoom=false] - Zoom on dragging through
* double-click gesture ( single click and next click to drag). Note: If set to true
* then clickToZoom should be set to false to prevent multiple zooms.
* @property {Boolean} [gestureSettingsMouse.pinchToZoom=false] - Zoom on pinch gesture * @property {Boolean} [gestureSettingsMouse.pinchToZoom=false] - Zoom on pinch gesture
* @property {Boolean} [gestureSettingsMouse.zoomToRefPoint=true] - If zoomToRefPoint is true, the zoom is centered at the pointer position. Otherwise, * @property {Boolean} [gestureSettingsMouse.zoomToRefPoint=true] - If zoomToRefPoint is true, the zoom is centered at the pointer position. Otherwise,
* the zoom is centered at the canvas center. * the zoom is centered at the canvas center.
@ -356,6 +359,10 @@
* @property {Boolean} [gestureSettingsTouch.clickToZoom=false] - Zoom on click gesture * @property {Boolean} [gestureSettingsTouch.clickToZoom=false] - Zoom on click gesture
* @property {Boolean} [gestureSettingsTouch.dblClickToZoom=true] - Zoom on double-click gesture. Note: If set to true * @property {Boolean} [gestureSettingsTouch.dblClickToZoom=true] - Zoom on double-click gesture. Note: If set to true
* then clickToZoom should be set to false to prevent multiple zooms. * then clickToZoom should be set to false to prevent multiple zooms.
* @property {Boolean} [gestureSettingsTouch.dblClickDragToZoom=true] - Zoom on dragging through
* double-click gesture ( single click and next click to drag). Note: If set to true
* then clickToZoom should be set to false to prevent multiple zooms.
* @property {Boolean} [gestureSettingsTouch.pinchToZoom=true] - Zoom on pinch gesture * @property {Boolean} [gestureSettingsTouch.pinchToZoom=true] - Zoom on pinch gesture
* @property {Boolean} [gestureSettingsTouch.zoomToRefPoint=true] - If zoomToRefPoint is true, the zoom is centered at the pointer position. Otherwise, * @property {Boolean} [gestureSettingsTouch.zoomToRefPoint=true] - If zoomToRefPoint is true, the zoom is centered at the pointer position. Otherwise,
* the zoom is centered at the canvas center. * the zoom is centered at the canvas center.
@ -386,6 +393,9 @@
* @property {Boolean} [gestureSettingsUnknown.clickToZoom=false] - Zoom on click gesture * @property {Boolean} [gestureSettingsUnknown.clickToZoom=false] - Zoom on click gesture
* @property {Boolean} [gestureSettingsUnknown.dblClickToZoom=true] - Zoom on double-click gesture. Note: If set to true * @property {Boolean} [gestureSettingsUnknown.dblClickToZoom=true] - Zoom on double-click gesture. Note: If set to true
* then clickToZoom should be set to false to prevent multiple zooms. * then clickToZoom should be set to false to prevent multiple zooms.
* @property {Boolean} [gestureSettingsUnknown.dblClickDragToZoom=false] - Zoom on dragging through
* double-click gesture ( single click and next click to drag). Note: If set to true
* then clickToZoom should be set to false to prevent multiple zooms.
* @property {Boolean} [gestureSettingsUnknown.pinchToZoom=true] - Zoom on pinch gesture * @property {Boolean} [gestureSettingsUnknown.pinchToZoom=true] - Zoom on pinch gesture
* @property {Boolean} [gestureSettingsUnknown.zoomToRefPoint=true] - If zoomToRefPoint is true, the zoom is centered at the pointer position. Otherwise, * @property {Boolean} [gestureSettingsUnknown.zoomToRefPoint=true] - If zoomToRefPoint is true, the zoom is centered at the pointer position. Otherwise,
* the zoom is centered at the canvas center. * the zoom is centered at the canvas center.
@ -400,6 +410,9 @@
* @property {Number} [zoomPerScroll=1.2] * @property {Number} [zoomPerScroll=1.2]
* The "zoom distance" per mouse scroll or touch pinch. <em><strong>Note:</strong> Setting this to 1.0 effectively disables the mouse-wheel zoom feature (also see gestureSettings[Mouse|Touch|Pen].scrollToZoom}).</em> * The "zoom distance" per mouse scroll or touch pinch. <em><strong>Note:</strong> Setting this to 1.0 effectively disables the mouse-wheel zoom feature (also see gestureSettings[Mouse|Touch|Pen].scrollToZoom}).</em>
* *
* @property {Number} [zoomPerDblClickDrag=1.2]
* The "zoom distance" per double-click mouse drag. <em><strong>Note:</strong> Setting this to 1.0 effectively disables the double-click-drag-to-Zoom feature (also see gestureSettings[Mouse|Touch|Pen].dblClickDragToZoom).</em>
*
* @property {Number} [zoomPerSecond=1.0] * @property {Number} [zoomPerSecond=1.0]
* Sets the zoom amount per second when zoomIn/zoomOut buttons are pressed and held. * Sets the zoom amount per second when zoomIn/zoomOut buttons are pressed and held.
* The value is a factor of the current zoom, so 1.0 (the default) disables zooming when the zoomIn/zoomOut buttons * The value is a factor of the current zoom, so 1.0 (the default) disables zooming when the zoomIn/zoomOut buttons
@ -1203,6 +1216,7 @@ function OpenSeadragon( options ){
scrollToZoom: true, scrollToZoom: true,
clickToZoom: true, clickToZoom: true,
dblClickToZoom: false, dblClickToZoom: false,
dblClickDragToZoom: false,
pinchToZoom: false, pinchToZoom: false,
zoomToRefPoint: true, zoomToRefPoint: true,
flickEnabled: false, flickEnabled: false,
@ -1215,6 +1229,7 @@ function OpenSeadragon( options ){
scrollToZoom: false, scrollToZoom: false,
clickToZoom: false, clickToZoom: false,
dblClickToZoom: true, dblClickToZoom: true,
dblClickDragToZoom: true,
pinchToZoom: true, pinchToZoom: true,
zoomToRefPoint: true, zoomToRefPoint: true,
flickEnabled: true, flickEnabled: true,
@ -1227,6 +1242,7 @@ function OpenSeadragon( options ){
scrollToZoom: false, scrollToZoom: false,
clickToZoom: true, clickToZoom: true,
dblClickToZoom: false, dblClickToZoom: false,
dblClickDragToZoom: false,
pinchToZoom: false, pinchToZoom: false,
zoomToRefPoint: true, zoomToRefPoint: true,
flickEnabled: false, flickEnabled: false,
@ -1239,6 +1255,7 @@ function OpenSeadragon( options ){
scrollToZoom: false, scrollToZoom: false,
clickToZoom: false, clickToZoom: false,
dblClickToZoom: true, dblClickToZoom: true,
dblClickDragToZoom: false,
pinchToZoom: true, pinchToZoom: true,
zoomToRefPoint: true, zoomToRefPoint: true,
flickEnabled: true, flickEnabled: true,
@ -1248,6 +1265,7 @@ function OpenSeadragon( options ){
}, },
zoomPerClick: 2, zoomPerClick: 2,
zoomPerScroll: 1.2, zoomPerScroll: 1.2,
zoomPerDblClickDrag: 1.2,
zoomPerSecond: 1.0, zoomPerSecond: 1.0,
blendTime: 0, blendTime: 0,
alwaysBlend: false, alwaysBlend: false,

View File

@ -212,7 +212,9 @@ $.Viewer = function( options ) {
zoomFactor: null, zoomFactor: null,
lastZoomTime: null, lastZoomTime: null,
fullPage: false, fullPage: false,
onfullscreenchange: null onfullscreenchange: null,
lastClickTime: null,
draggingToZoom: false,
}; };
this._sequenceIndex = 0; this._sequenceIndex = 0;
@ -2854,6 +2856,8 @@ function onCanvasKeyPress( event ) {
} }
} }
function onCanvasClick( event ) { function onCanvasClick( event ) {
var gestureSettings; var gestureSettings;
@ -2893,17 +2897,31 @@ function onCanvasClick( event ) {
* @property {Boolean} preventDefaultAction - Set to true to prevent default click to zoom behaviour. Default: false. * @property {Boolean} preventDefaultAction - Set to true to prevent default click to zoom behaviour. Default: false.
* @property {?Object} userData - Arbitrary subscriber-defined object. * @property {?Object} userData - Arbitrary subscriber-defined object.
*/ */
this.raiseEvent( 'canvas-click', canvasClickEventArgs); this.raiseEvent( 'canvas-click', canvasClickEventArgs);
if ( !canvasClickEventArgs.preventDefaultAction && this.viewport && event.quick ) { if ( !canvasClickEventArgs.preventDefaultAction && this.viewport && event.quick ) {
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType ); gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
if ( gestureSettings.clickToZoom ) {
if (gestureSettings.clickToZoom === true){
this.viewport.zoomBy( this.viewport.zoomBy(
event.shift ? 1.0 / this.zoomPerClick : this.zoomPerClick, event.shift ? 1.0 / this.zoomPerClick : this.zoomPerClick,
gestureSettings.zoomToRefPoint ? this.viewport.pointFromPixel( event.position, true ) : null gestureSettings.zoomToRefPoint ? this.viewport.pointFromPixel( event.position, true ) : null
); );
this.viewport.applyConstraints(); this.viewport.applyConstraints();
} }
if( gestureSettings.dblClickDragToZoom){
if(THIS[ this.hash ].draggingToZoom === true){
THIS[ this.hash ].lastClickTime = null;
THIS[ this.hash ].draggingToZoom = false;
}
else{
THIS[ this.hash ].lastClickTime = $.now();
}
}
} }
} }
@ -2983,43 +3001,52 @@ function onCanvasDrag( event ) {
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType ); gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
if ( gestureSettings.dragToPan && !canvasDragEventArgs.preventDefaultAction && this.viewport ) { if(!canvasDragEventArgs.preventDefaultAction && this.viewport){
if( !this.panHorizontal ){
event.delta.x = 0; if (gestureSettings.dblClickDragToZoom && THIS[ this.hash ].draggingToZoom){
var factor = Math.pow( this.zoomPerDblClickDrag, event.delta.y / 50);
this.viewport.zoomBy(factor);
} }
if( !this.panVertical ){ else if (gestureSettings.dragToPan && !THIS[ this.hash ].draggingToZoom) {
event.delta.y = 0; if( !this.panHorizontal ){
}
if(this.viewport.flipped){
event.delta.x = -event.delta.x;
}
if( this.constrainDuringPan ){
var delta = this.viewport.deltaPointsFromPixels( event.delta.negate() );
this.viewport.centerSpringX.target.value += delta.x;
this.viewport.centerSpringY.target.value += delta.y;
var bounds = this.viewport.getBounds();
var constrainedBounds = this.viewport.getConstrainedBounds();
this.viewport.centerSpringX.target.value -= delta.x;
this.viewport.centerSpringY.target.value -= delta.y;
if (bounds.x !== constrainedBounds.x) {
event.delta.x = 0; event.delta.x = 0;
} }
if( !this.panVertical ){
if (bounds.y !== constrainedBounds.y) {
event.delta.y = 0; event.delta.y = 0;
} }
if(this.viewport.flipped){
event.delta.x = -event.delta.x;
}
if( this.constrainDuringPan ){
var delta = this.viewport.deltaPointsFromPixels( event.delta.negate() );
this.viewport.centerSpringX.target.value += delta.x;
this.viewport.centerSpringY.target.value += delta.y;
var bounds = this.viewport.getBounds();
var constrainedBounds = this.viewport.getConstrainedBounds();
this.viewport.centerSpringX.target.value -= delta.x;
this.viewport.centerSpringY.target.value -= delta.y;
if (bounds.x !== constrainedBounds.x) {
event.delta.x = 0;
}
if (bounds.y !== constrainedBounds.y) {
event.delta.y = 0;
}
}
this.viewport.panBy( this.viewport.deltaPointsFromPixels( event.delta.negate() ), gestureSettings.flickEnabled && !this.constrainDuringPan);
} }
this.viewport.panBy( this.viewport.deltaPointsFromPixels( event.delta.negate() ), gestureSettings.flickEnabled && !this.constrainDuringPan);
} }
} }
function onCanvasDragEnd( event ) { function onCanvasDragEnd( event ) {
var gestureSettings;
var canvasDragEndEventArgs = { var canvasDragEndEventArgs = {
tracker: event.eventSource, tracker: event.eventSource,
pointerType: event.pointerType, pointerType: event.pointerType,
@ -3050,9 +3077,11 @@ function onCanvasDragEnd( event ) {
*/ */
this.raiseEvent('canvas-drag-end', canvasDragEndEventArgs); this.raiseEvent('canvas-drag-end', canvasDragEndEventArgs);
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
if (!canvasDragEndEventArgs.preventDefaultAction && this.viewport) { if (!canvasDragEndEventArgs.preventDefaultAction && this.viewport) {
var gestureSettings = this.gestureSettingsByDeviceType(event.pointerType); if ( !THIS[ this.hash ].draggingToZoom &&
if (gestureSettings.flickEnabled && gestureSettings.flickEnabled &&
event.speed >= gestureSettings.flickMinSpeed) { event.speed >= gestureSettings.flickMinSpeed) {
var amplitudeX = 0; var amplitudeX = 0;
if (this.panHorizontal) { if (this.panHorizontal) {
@ -3072,6 +3101,13 @@ function onCanvasDragEnd( event ) {
} }
this.viewport.applyConstraints(); this.viewport.applyConstraints();
} }
if( gestureSettings.dblClickDragToZoom && THIS[ this.hash ].draggingToZoom === true ){
THIS[ this.hash ].draggingToZoom = false;
}
} }
function onCanvasEnter( event ) { function onCanvasEnter( event ) {
@ -3135,6 +3171,8 @@ function onCanvasLeave( event ) {
} }
function onCanvasPress( event ) { function onCanvasPress( event ) {
var gestureSettings;
/** /**
* Raised when the primary mouse button is pressed or touch starts on the {@link OpenSeadragon.Viewer#canvas} element. * Raised when the primary mouse button is pressed or touch starts on the {@link OpenSeadragon.Viewer#canvas} element.
* *
@ -3158,6 +3196,24 @@ function onCanvasPress( event ) {
insideElementReleased: event.insideElementReleased, insideElementReleased: event.insideElementReleased,
originalEvent: event.originalEvent originalEvent: event.originalEvent
}); });
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
if ( gestureSettings.dblClickDragToZoom ){
var lastClickTime = THIS[ this.hash ].lastClickTime;
var currClickTime = $.now();
if ( lastClickTime === null) {
return;
}
if ((currClickTime - lastClickTime) < this.dblClickTimeThreshold) {
THIS[ this.hash ].draggingToZoom = true;
}
THIS[ this.hash ].lastClickTime = null;
}
} }
function onCanvasRelease( event ) { function onCanvasRelease( event ) {