Default/options/member variable cleanup

Clean up before fixing/adding features
This commit is contained in:
Mark Salsbery 2023-08-11 23:52:15 -07:00
parent f683a32e32
commit 406baa1891
3 changed files with 48 additions and 56 deletions

View File

@ -645,18 +645,18 @@
* If sequenceMode is true, then display a scrolling strip of image thumbnails for * If sequenceMode is true, then display a scrolling strip of image thumbnails for
* navigating through the images. * navigating through the images.
* *
* @property {String} [referenceStripScroll='horizontal']
*
* @property {Element} [referenceStripId=null] * @property {Element} [referenceStripId=null]
* *
* @property {Number} [referenceStripHeight=null] * @property {String} [referenceStripScroll='horizontal']
*
* @property {Number} [referenceStripWidth=null]
* *
* @property {String} [referenceStripPosition='BOTTOM_LEFT'] * @property {String} [referenceStripPosition='BOTTOM_LEFT']
* *
* @property {Number} [referenceStripSizeRatio=0.2] * @property {Number} [referenceStripSizeRatio=0.2]
* *
* @property {Number} [referenceStripHeight=null]
*
* @property {Number} [referenceStripWidth=null]
*
* @property {Boolean} [collectionMode=false] * @property {Boolean} [collectionMode=false]
* Set to true to have the viewer arrange your TiledImages in a grid or line. * Set to true to have the viewer arrange your TiledImages in a grid or line.
* *
@ -1348,12 +1348,12 @@ function OpenSeadragon( options ){
//REFERENCE STRIP SETTINGS //REFERENCE STRIP SETTINGS
showReferenceStrip: false, showReferenceStrip: false,
referenceStripScroll: 'horizontal',
referenceStripId: null, referenceStripId: null,
referenceStripHeight: null, referenceStripScroll: 'horizontal',
referenceStripWidth: null,
referenceStripPosition: 'BOTTOM_LEFT', referenceStripPosition: 'BOTTOM_LEFT',
referenceStripSizeRatio: 0.2, referenceStripSizeRatio: 0.2,
referenceStripHeight: null,
referenceStripWidth: null,
//COLLECTION VISUALIZATION SETTINGS //COLLECTION VISUALIZATION SETTINGS
collectionRows: 3, //or columns depending on layout collectionRows: 3, //or columns depending on layout

View File

@ -64,24 +64,21 @@ const THIS = {};
$.ReferenceStrip = function ( options ) { $.ReferenceStrip = function ( options ) {
// //REFERENCE STRIP SETTINGS ($.DEFAULT_SETTINGS) // //REFERENCE STRIP SETTINGS ($.DEFAULT_SETTINGS)
// showReferenceStrip: false, // showReferenceStrip: false,
// referenceStripScroll: 'horizontal',
// referenceStripId: null, // referenceStripId: null,
// referenceStripHeight: null, // referenceStripScroll: 'horizontal',
// referenceStripWidth: null,
// referenceStripPosition: 'BOTTOM_LEFT', // referenceStripPosition: 'BOTTOM_LEFT',
// referenceStripSizeRatio: 0.2, // referenceStripSizeRatio: 0.2,
// referenceStripHeight: null,
// referenceStripWidth: null,
// this.referenceStrip = new $.ReferenceStrip({ // this.referenceStrip = new $.ReferenceStrip({
// viewer: this,
// id: this.referenceStripId, // id: this.referenceStripId,
// scroll: this.referenceStripScroll,
// position: this.referenceStripPosition, // position: this.referenceStripPosition,
// sizeRatio: this.referenceStripSizeRatio, // sizeRatio: this.referenceStripSizeRatio,
// scroll: this.referenceStripScroll,
// height: this.referenceStripHeight, // height: this.referenceStripHeight,
// width: this.referenceStripWidth, // width: this.referenceStripWidth
// tileSources: this.tileSources,
// prefixUrl: this.prefixUrl,
// useCanvas: this.useCanvas,
// viewer: this
// }); // });
const viewer = options.viewer, const viewer = options.viewer,
@ -102,15 +99,12 @@ $.ReferenceStrip = function ( options ) {
sizeRatio: $.DEFAULT_SETTINGS.referenceStripSizeRatio, sizeRatio: $.DEFAULT_SETTINGS.referenceStripSizeRatio,
position: $.DEFAULT_SETTINGS.referenceStripPosition, position: $.DEFAULT_SETTINGS.referenceStripPosition,
scroll: $.DEFAULT_SETTINGS.referenceStripScroll, scroll: $.DEFAULT_SETTINGS.referenceStripScroll,
clickTimeThreshold: $.DEFAULT_SETTINGS.clickTimeThreshold
}, },
options, options
{
element: this.stripElement
}
); );
$.extend( this, options ); $.extend( this, options );
//Private state properties //Private state properties
THIS[this.id] = { THIS[this.id] = {
animating: false animating: false
@ -135,17 +129,18 @@ $.ReferenceStrip = function ( options ) {
$.setElementOpacity( this.stripElement, 0.8 ); $.setElementOpacity( this.stripElement, 0.8 );
this.viewer = viewer; this.stripTracker = new $.MouseTracker( {
this.tracker = new $.MouseTracker( { userData: 'ReferenceStrip.stripTracker',
userData: 'ReferenceStrip.tracker',
element: this.stripElement, element: this.stripElement,
clickTimeThreshold: viewer.clickTimeThreshold || $.DEFAULT_SETTINGS.clickTimeThreshold,
clickDistThreshold: viewer.clickDistThreshold || $.DEFAULT_SETTINGS.clickDistThreshold,
clickHandler: $.delegate( this, onStripClick ), clickHandler: $.delegate( this, onStripClick ),
dragHandler: $.delegate( this, onStripDrag ), dragHandler: $.delegate( this, onStripDrag ),
scrollHandler: $.delegate( this, onStripScroll ), scrollHandler: $.delegate( this, onStripScroll ),
enterHandler: $.delegate( this, onStripEnter ), enterHandler: $.delegate( this, onStripEnter ),
leaveHandler: $.delegate( this, onStripLeave ), leaveHandler: $.delegate( this, onStripLeave ),
keyDownHandler: $.delegate( this, onKeyDown ), keyDownHandler: $.delegate( this, onStripKeyDown ),
keyHandler: $.delegate( this, onKeyPress ), keyHandler: $.delegate( this, onStripKeyPress ),
preProcessEventHandler: function (eventInfo) { preProcessEventHandler: function (eventInfo) {
if (eventInfo.eventType === 'wheel') { if (eventInfo.eventType === 'wheel') {
eventInfo.preventDefault = true; eventInfo.preventDefault = true;
@ -280,7 +275,7 @@ $.ReferenceStrip.prototype = {
} }
this.currentPage = page; this.currentPage = page;
onStripEnter.call( this, { eventSource: this.tracker } ); onStripEnter.call( this, { eventSource: this.stripTracker } );
} }
}, },
@ -302,7 +297,7 @@ $.ReferenceStrip.prototype = {
} }
} }
this.tracker.destroy(); this.stripTracker.destroy();
if (this.stripElement) { if (this.stripElement) {
this.viewer.removeControl( this.stripElement ); this.viewer.removeControl( this.stripElement );
@ -404,28 +399,28 @@ function onStripScroll( event ) {
if ( event.scroll > 0 ) { if ( event.scroll > 0 ) {
//forward //forward
if ( offsetLeft > -( scrollWidth - viewerSize.x ) ) { if ( offsetLeft > -( scrollWidth - viewerSize.x ) ) {
this.stripElement.style.marginLeft = ( offsetLeft - ( event.scroll * 60 ) ) + 'px'; this.stripElement.style.marginLeft = ( offsetLeft - ( event.scroll * 50 ) ) + 'px';
loadPanels( this, viewerSize.x, offsetLeft - ( event.scroll * 60 ) ); loadPanels( this, viewerSize.x, offsetLeft - ( event.scroll * 50 ) );
} }
} else if ( event.scroll < 0 ) { } else if ( event.scroll < 0 ) {
//reverse //reverse
if ( offsetLeft < 0 ) { if ( offsetLeft < 0 ) {
this.stripElement.style.marginLeft = ( offsetLeft - ( event.scroll * 60 ) ) + 'px'; this.stripElement.style.marginLeft = ( offsetLeft - ( event.scroll * 50 ) ) + 'px';
loadPanels( this, viewerSize.x, offsetLeft - ( event.scroll * 60 ) ); loadPanels( this, viewerSize.x, offsetLeft - ( event.scroll * 50 ) );
} }
} }
} else { } else {
if ( event.scroll < 0 ) { if ( event.scroll < 0 ) {
//scroll up //scroll up
if ( offsetTop > viewerSize.y - scrollHeight ) { if ( offsetTop > viewerSize.y - scrollHeight ) {
this.stripElement.style.marginTop = ( offsetTop + ( event.scroll * 60 ) ) + 'px'; this.stripElement.style.marginTop = ( offsetTop + ( event.scroll * 50 ) ) + 'px';
loadPanels( this, viewerSize.y, offsetTop + ( event.scroll * 60 ) ); loadPanels( this, viewerSize.y, offsetTop + ( event.scroll * 50 ) );
} }
} else if ( event.scroll > 0 ) { } else if ( event.scroll > 0 ) {
//scroll dowm //scroll dowm
if ( offsetTop < 0 ) { if ( offsetTop < 0 ) {
this.stripElement.style.marginTop = ( offsetTop + ( event.scroll * 60 ) ) + 'px'; this.stripElement.style.marginTop = ( offsetTop + ( event.scroll * 50 ) ) + 'px';
loadPanels( this, viewerSize.y, offsetTop + ( event.scroll * 60 ) ); loadPanels( this, viewerSize.y, offsetTop + ( event.scroll * 50 ) );
} }
} }
} }
@ -474,7 +469,7 @@ function loadPanels( strip, viewerSize, scroll ) {
animationTime: 0, animationTime: 0,
loadTilesWithAjax: strip.viewer.loadTilesWithAjax, loadTilesWithAjax: strip.viewer.loadTilesWithAjax,
ajaxHeaders: strip.viewer.ajaxHeaders, ajaxHeaders: strip.viewer.ajaxHeaders,
useCanvas: strip.useCanvas useCanvas: strip.viewer.useCanvas || $.DEFAULT_SETTINGS.useCanvas
} ); } );
// Allow pointer events to pass through miniViewer's canvas/container // Allow pointer events to pass through miniViewer's canvas/container
// elements so implicit pointer capture works on touch devices // elements so implicit pointer capture works on touch devices
@ -547,25 +542,25 @@ function onStripLeave( event ) {
* @inner * @inner
* @function * @function
*/ */
function onKeyDown( event ) { function onStripKeyDown( event ) {
//console.log( event.keyCode ); //console.log( event.keyCode );
if ( !event.ctrl && !event.alt && !event.meta ) { if ( !event.ctrl && !event.alt && !event.meta ) {
switch ( event.keyCode ) { switch ( event.keyCode ) {
case 38: //up arrow case 38: //up arrow
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: 1, shift: null } ); onStripScroll.call( this, { eventSource: this.stripTracker, position: null, scroll: 1, shift: null } );
event.preventDefault = true; event.preventDefault = true;
break; break;
case 40: //down arrow case 40: //down arrow
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: -1, shift: null } ); onStripScroll.call( this, { eventSource: this.stripTracker, position: null, scroll: -1, shift: null } );
event.preventDefault = true; event.preventDefault = true;
break; break;
case 37: //left arrow case 37: //left arrow
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: -1, shift: null } ); onStripScroll.call( this, { eventSource: this.stripTracker, position: null, scroll: -1, shift: null } );
event.preventDefault = true; event.preventDefault = true;
break; break;
case 39: //right arrow case 39: //right arrow
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: 1, shift: null } ); onStripScroll.call( this, { eventSource: this.stripTracker, position: null, scroll: 1, shift: null } );
event.preventDefault = true; event.preventDefault = true;
break; break;
default: default:
@ -584,36 +579,36 @@ function onKeyDown( event ) {
* @inner * @inner
* @function * @function
*/ */
function onKeyPress( event ) { function onStripKeyPress( event ) {
//console.log( event.keyCode ); //console.log( event.keyCode );
if ( !event.ctrl && !event.alt && !event.meta ) { if ( !event.ctrl && !event.alt && !event.meta ) {
switch ( event.keyCode ) { switch ( event.keyCode ) {
case 61: //=|+ case 61: //=|+
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: 1, shift: null } ); onStripScroll.call( this, { eventSource: this.stripTracker, position: null, scroll: 1, shift: null } );
event.preventDefault = true; event.preventDefault = true;
break; break;
case 45: //-|_ case 45: //-|_
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: -1, shift: null } ); onStripScroll.call( this, { eventSource: this.stripTracker, position: null, scroll: -1, shift: null } );
event.preventDefault = true; event.preventDefault = true;
break; break;
case 48: //0|) case 48: //0|)
case 119: //w case 119: //w
case 87: //W case 87: //W
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: 1, shift: null } ); onStripScroll.call( this, { eventSource: this.stripTracker, position: null, scroll: 1, shift: null } );
event.preventDefault = true; event.preventDefault = true;
break; break;
case 115: //s case 115: //s
case 83: //S case 83: //S
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: -1, shift: null } ); onStripScroll.call( this, { eventSource: this.stripTracker, position: null, scroll: -1, shift: null } );
event.preventDefault = true; event.preventDefault = true;
break; break;
case 97: //a case 97: //a
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: -1, shift: null } ); onStripScroll.call( this, { eventSource: this.stripTracker, position: null, scroll: -1, shift: null } );
event.preventDefault = true; event.preventDefault = true;
break; break;
case 100: //d case 100: //d
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: 1, shift: null } ); onStripScroll.call( this, { eventSource: this.stripTracker, position: null, scroll: 1, shift: null } );
event.preventDefault = true; event.preventDefault = true;
break; break;
default: default:

View File

@ -2395,16 +2395,13 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
if (this.tileSources.length && this.tileSources.length > 1) { if (this.tileSources.length && this.tileSources.length > 1) {
this.referenceStrip = new $.ReferenceStrip({ this.referenceStrip = new $.ReferenceStrip({
viewer: this,
id: this.referenceStripId, id: this.referenceStripId,
scroll: this.referenceStripScroll,
position: this.referenceStripPosition, position: this.referenceStripPosition,
sizeRatio: this.referenceStripSizeRatio, sizeRatio: this.referenceStripSizeRatio,
scroll: this.referenceStripScroll,
height: this.referenceStripHeight, height: this.referenceStripHeight,
width: this.referenceStripWidth, width: this.referenceStripWidth
tileSources: this.tileSources,
prefixUrl: this.prefixUrl,
useCanvas: this.useCanvas,
viewer: this
}); });
this.referenceStrip.setFocus( this._sequenceIndex ); this.referenceStrip.setFocus( this._sequenceIndex );