Merge pull request #2007 from RammasEchor/master

Add keys to change image source in sequence mode
This commit is contained in:
Ian Gilman 2021-07-13 11:11:17 -07:00 committed by GitHub
commit fc7a4b93f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1646,8 +1646,8 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
var onFocusHandler = $.delegate( this, onFocus ), var onFocusHandler = $.delegate( this, onFocus ),
onBlurHandler = $.delegate( this, onBlur ), onBlurHandler = $.delegate( this, onBlur ),
onNextHandler = $.delegate( this, onNext ), onNextHandler = $.delegate( this, this.goToNextPage ),
onPreviousHandler = $.delegate( this, onPrevious ), onPreviousHandler = $.delegate( this, this.goToPreviousPage ),
navImages = this.navImages, navImages = this.navImages,
useGroup = true; useGroup = true;
@ -2316,7 +2316,40 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
this.world.resetItems(); this.world.resetItems();
this.forceRedraw(); this.forceRedraw();
} }
},
/**
* Sets the image source to the source with index equal to
* currentIndex - 1. Changes current image in sequence mode.
* If specified, wraps around (see navPrevNextWrap in
* {@link OpenSeadragon.Options})
*
* @method
*/
goToPreviousPage: function () {
var previous = this._sequenceIndex - 1;
if(this.navPrevNextWrap && previous < 0){
previous += this.tileSources.length;
} }
this.goToPage( previous );
},
/**
* Sets the image source to the source with index equal to
* currentIndex + 1. Changes current image in sequence mode.
* If specified, wraps around (see navPrevNextWrap in
* {@link OpenSeadragon.Options})
*
* @method
*/
goToNextPage: function () {
var next = this._sequenceIndex + 1;
if(this.navPrevNextWrap && next >= this.tileSources.length){
next = 0;
}
this.goToPage( next );
},
}); });
@ -2782,6 +2815,12 @@ function onCanvasKeyPress( event ) {
this.viewport.toggleFlip(); this.viewport.toggleFlip();
event.preventDefault = true; event.preventDefault = true;
break; break;
case 106: //j - previous image source
this.goToPreviousPage();
break;
case 107: //k - next image source
this.goToNextPage();
break;
default: default:
// console.log( 'navigator keycode %s', event.keyCode ); // console.log( 'navigator keycode %s', event.keyCode );
event.preventDefault = false; event.preventDefault = false;
@ -3671,22 +3710,4 @@ function onFlip() {
this.viewport.toggleFlip(); this.viewport.toggleFlip();
} }
function onPrevious(){
var previous = this._sequenceIndex - 1;
if(this.navPrevNextWrap && previous < 0){
previous += this.tileSources.length;
}
this.goToPage( previous );
}
function onNext(){
var next = this._sequenceIndex + 1;
if(this.navPrevNextWrap && next >= this.tileSources.length){
next = 0;
}
this.goToPage( next );
}
}( OpenSeadragon )); }( OpenSeadragon ));