2013-05-01 08:46:16 +04:00
|
|
|
/*
|
2013-05-14 08:00:24 +04:00
|
|
|
* OpenSeadragon - ReferenceStrip
|
2013-05-01 08:46:16 +04:00
|
|
|
*
|
|
|
|
* Copyright (C) 2009 CodePlex Foundation
|
2023-12-15 03:14:05 +03:00
|
|
|
* Copyright (C) 2010-2024 OpenSeadragon contributors
|
2013-05-01 08:46:16 +04:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met:
|
|
|
|
*
|
|
|
|
* - Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* - Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* - Neither the name of CodePlex Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
|
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
|
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
2013-02-13 07:40:08 +04:00
|
|
|
|
2013-09-06 04:20:17 +04:00
|
|
|
(function ( $ ) {
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
// dictionary from id to private properties
|
|
|
|
var THIS = {};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The CollectionDrawer is a reimplementation if the Drawer API that
|
|
|
|
* focuses on allowing a viewport to be redefined as a collection
|
|
|
|
* of smaller viewports, defined by a clear number of rows and / or
|
|
|
|
* columns of which each item in the matrix of viewports has its own
|
|
|
|
* source.
|
|
|
|
*
|
|
|
|
* This idea is a reexpression of the idea of dzi collections
|
|
|
|
* which allows a clearer algorithm to reuse the tile sources already
|
2023-12-19 23:57:15 +03:00
|
|
|
* supported by OpenSeadragon, in heterogeneous or homogeneous
|
2013-09-06 21:43:39 +04:00
|
|
|
* sequences just like mixed groups already supported by the viewer
|
|
|
|
* for the purpose of image sequnces.
|
|
|
|
*
|
|
|
|
* TODO: The difficult part of this feature is figuring out how to express
|
|
|
|
* this functionality as a combination of the functionality already
|
|
|
|
* provided by Drawer, Viewport, TileSource, and Navigator. It may
|
2018-09-01 11:59:20 +03:00
|
|
|
* require better abstraction at those points in order to efficiently
|
2013-09-06 21:43:39 +04:00
|
|
|
* reuse those paradigms.
|
|
|
|
*/
|
2013-11-25 20:48:44 +04:00
|
|
|
/**
|
|
|
|
* @class ReferenceStrip
|
|
|
|
* @memberof OpenSeadragon
|
|
|
|
* @param {Object} options
|
|
|
|
*/
|
2013-09-06 21:43:39 +04:00
|
|
|
$.ReferenceStrip = function ( options ) {
|
|
|
|
|
2013-09-06 22:10:05 +04:00
|
|
|
var _this = this,
|
|
|
|
viewer = options.viewer,
|
|
|
|
viewerSize = $.getElementSize( viewer.element ),
|
|
|
|
element,
|
|
|
|
style,
|
|
|
|
i;
|
2013-09-06 21:43:39 +04:00
|
|
|
|
|
|
|
//We may need to create a new element and id if they did not
|
|
|
|
//provide the id for the existing element
|
|
|
|
if ( !options.id ) {
|
2013-09-06 22:10:05 +04:00
|
|
|
options.id = 'referencestrip-' + $.now();
|
|
|
|
this.element = $.makeNeutralElement( "div" );
|
|
|
|
this.element.id = options.id;
|
|
|
|
this.element.className = 'referencestrip';
|
2013-09-06 21:43:39 +04:00
|
|
|
}
|
2012-09-05 18:52:57 +04:00
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
options = $.extend( true, {
|
2013-09-06 22:10:05 +04:00
|
|
|
sizeRatio: $.DEFAULT_SETTINGS.referenceStripSizeRatio,
|
|
|
|
position: $.DEFAULT_SETTINGS.referenceStripPosition,
|
|
|
|
scroll: $.DEFAULT_SETTINGS.referenceStripScroll,
|
|
|
|
clickTimeThreshold: $.DEFAULT_SETTINGS.clickTimeThreshold
|
2013-09-06 21:43:39 +04:00
|
|
|
}, options, {
|
2020-08-13 07:22:48 +03:00
|
|
|
element: this.element
|
2013-09-06 21:43:39 +04:00
|
|
|
} );
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
$.extend( this, options );
|
|
|
|
//Private state properties
|
|
|
|
THIS[this.id] = {
|
2020-06-26 02:01:14 +03:00
|
|
|
animating: false
|
2013-09-06 21:43:39 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
this.minPixelRatio = this.viewer.minPixelRatio;
|
|
|
|
|
2021-03-17 23:04:13 +03:00
|
|
|
this.element.tabIndex = 0;
|
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
style = this.element.style;
|
2013-09-06 22:10:05 +04:00
|
|
|
style.marginTop = '0px';
|
|
|
|
style.marginRight = '0px';
|
|
|
|
style.marginBottom = '0px';
|
|
|
|
style.marginLeft = '0px';
|
|
|
|
style.left = '0px';
|
|
|
|
style.bottom = '0px';
|
|
|
|
style.border = '0px';
|
|
|
|
style.background = '#000';
|
|
|
|
style.position = 'relative';
|
2013-09-06 21:43:39 +04:00
|
|
|
|
2014-08-06 03:57:54 +04:00
|
|
|
$.setElementTouchActionNone( this.element );
|
2014-08-05 08:41:07 +04:00
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
$.setElementOpacity( this.element, 0.8 );
|
|
|
|
|
|
|
|
this.viewer = viewer;
|
2020-08-13 07:22:48 +03:00
|
|
|
this.tracker = new $.MouseTracker( {
|
|
|
|
userData: 'ReferenceStrip.tracker',
|
2013-09-06 22:10:05 +04:00
|
|
|
element: this.element,
|
2020-08-13 07:22:48 +03:00
|
|
|
clickHandler: $.delegate( this, onStripClick ),
|
2013-09-06 22:10:05 +04:00
|
|
|
dragHandler: $.delegate( this, onStripDrag ),
|
|
|
|
scrollHandler: $.delegate( this, onStripScroll ),
|
|
|
|
enterHandler: $.delegate( this, onStripEnter ),
|
2020-07-25 06:05:39 +03:00
|
|
|
leaveHandler: $.delegate( this, onStripLeave ),
|
2015-01-17 03:26:30 +03:00
|
|
|
keyDownHandler: $.delegate( this, onKeyDown ),
|
2021-03-16 20:40:36 +03:00
|
|
|
keyHandler: $.delegate( this, onKeyPress ),
|
|
|
|
preProcessEventHandler: function (eventInfo) {
|
2021-03-16 21:37:32 +03:00
|
|
|
if (eventInfo.eventType === 'wheel') {
|
|
|
|
eventInfo.preventDefault = true;
|
2021-03-16 20:40:36 +03:00
|
|
|
}
|
|
|
|
}
|
2015-01-21 05:35:58 +03:00
|
|
|
} );
|
2013-09-06 21:43:39 +04:00
|
|
|
|
|
|
|
//Controls the position and orientation of the reference strip and sets the
|
|
|
|
//appropriate width and height
|
|
|
|
if ( options.width && options.height ) {
|
2013-09-06 22:10:05 +04:00
|
|
|
this.element.style.width = options.width + 'px';
|
2013-09-06 21:43:39 +04:00
|
|
|
this.element.style.height = options.height + 'px';
|
|
|
|
viewer.addControl(
|
2013-09-06 22:10:05 +04:00
|
|
|
this.element,
|
|
|
|
{ anchor: $.ControlAnchor.BOTTOM_LEFT }
|
|
|
|
);
|
2013-09-06 21:43:39 +04:00
|
|
|
} else {
|
2020-06-26 02:01:14 +03:00
|
|
|
if ( "horizontal" === options.scroll ) {
|
2013-09-06 21:43:39 +04:00
|
|
|
this.element.style.width = (
|
2013-09-06 22:10:05 +04:00
|
|
|
viewerSize.x *
|
|
|
|
options.sizeRatio *
|
|
|
|
viewer.tileSources.length
|
|
|
|
) + ( 12 * viewer.tileSources.length ) + 'px';
|
2013-09-06 21:43:39 +04:00
|
|
|
|
|
|
|
this.element.style.height = (
|
2013-09-06 22:10:05 +04:00
|
|
|
viewerSize.y *
|
|
|
|
options.sizeRatio
|
|
|
|
) + 'px';
|
2013-09-06 04:20:17 +04:00
|
|
|
|
|
|
|
viewer.addControl(
|
2013-09-06 22:10:05 +04:00
|
|
|
this.element,
|
|
|
|
{ anchor: $.ControlAnchor.BOTTOM_LEFT }
|
|
|
|
);
|
2013-09-06 04:20:17 +04:00
|
|
|
} else {
|
2013-09-06 21:43:39 +04:00
|
|
|
this.element.style.height = (
|
2013-09-06 22:10:05 +04:00
|
|
|
viewerSize.y *
|
|
|
|
options.sizeRatio *
|
|
|
|
viewer.tileSources.length
|
|
|
|
) + ( 12 * viewer.tileSources.length ) + 'px';
|
2013-09-06 04:20:17 +04:00
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
this.element.style.width = (
|
2013-09-06 22:10:05 +04:00
|
|
|
viewerSize.x *
|
|
|
|
options.sizeRatio
|
|
|
|
) + 'px';
|
2013-09-06 04:20:17 +04:00
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
viewer.addControl(
|
2013-09-06 22:10:05 +04:00
|
|
|
this.element,
|
|
|
|
{ anchor: $.ControlAnchor.TOP_LEFT }
|
|
|
|
);
|
2013-09-06 04:20:17 +04:00
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
}
|
|
|
|
}
|
2013-09-06 04:20:17 +04:00
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
this.panelWidth = ( viewerSize.x * this.sizeRatio ) + 8;
|
|
|
|
this.panelHeight = ( viewerSize.y * this.sizeRatio ) + 8;
|
|
|
|
this.panels = [];
|
2017-04-25 22:07:37 +03:00
|
|
|
this.miniViewers = {};
|
2013-09-06 21:43:39 +04:00
|
|
|
|
|
|
|
/*jshint loopfunc:true*/
|
|
|
|
for ( i = 0; i < viewer.tileSources.length; i++ ) {
|
|
|
|
|
|
|
|
element = $.makeNeutralElement( 'div' );
|
|
|
|
element.id = this.element.id + "-" + i;
|
|
|
|
|
2013-09-06 22:10:05 +04:00
|
|
|
element.style.width = _this.panelWidth + 'px';
|
|
|
|
element.style.height = _this.panelHeight + 'px';
|
|
|
|
element.style.display = 'inline';
|
2020-08-13 07:22:48 +03:00
|
|
|
element.style['float'] = 'left'; //Webkit
|
2013-09-06 22:10:05 +04:00
|
|
|
element.style.cssFloat = 'left'; //Firefox
|
|
|
|
element.style.styleFloat = 'left'; //IE
|
|
|
|
element.style.padding = '2px';
|
2014-08-06 03:57:54 +04:00
|
|
|
$.setElementTouchActionNone( element );
|
2020-08-13 07:22:48 +03:00
|
|
|
$.setElementPointerEventsNone( element );
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
this.element.appendChild( element );
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
element.activePanel = false;
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
this.panels.push( element );
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
}
|
2020-06-26 02:01:14 +03:00
|
|
|
loadPanels( this, this.scroll === 'vertical' ? viewerSize.y : viewerSize.x, 0 );
|
2013-09-06 21:43:39 +04:00
|
|
|
this.setFocus( 0 );
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
};
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
/** @lends OpenSeadragon.ReferenceStrip.prototype */
|
|
|
|
$.ReferenceStrip.prototype = {
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2013-11-25 20:48:44 +04:00
|
|
|
/**
|
|
|
|
* @function
|
|
|
|
*/
|
2013-09-06 21:43:39 +04:00
|
|
|
setFocus: function ( page ) {
|
2019-07-16 05:27:03 +03:00
|
|
|
var element = this.element.querySelector('#' + this.element.id + '-' + page ),
|
2013-09-10 01:27:58 +04:00
|
|
|
viewerSize = $.getElementSize( this.viewer.canvas ),
|
|
|
|
scrollWidth = Number( this.element.style.width.replace( 'px', '' ) ),
|
2013-09-06 22:10:05 +04:00
|
|
|
scrollHeight = Number( this.element.style.height.replace( 'px', '' ) ),
|
2013-09-10 01:27:58 +04:00
|
|
|
offsetLeft = -Number( this.element.style.marginLeft.replace( 'px', '' ) ),
|
|
|
|
offsetTop = -Number( this.element.style.marginTop.replace( 'px', '' ) ),
|
2013-09-06 22:10:05 +04:00
|
|
|
offset;
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
if ( this.currentSelected !== element ) {
|
|
|
|
if ( this.currentSelected ) {
|
|
|
|
this.currentSelected.style.background = '#000';
|
|
|
|
}
|
|
|
|
this.currentSelected = element;
|
|
|
|
this.currentSelected.style.background = '#999';
|
2012-10-13 07:40:59 +04:00
|
|
|
|
2020-06-26 02:01:14 +03:00
|
|
|
if ( 'horizontal' === this.scroll ) {
|
2013-09-06 21:43:39 +04:00
|
|
|
//right left
|
|
|
|
offset = ( Number( page ) ) * ( this.panelWidth + 3 );
|
|
|
|
if ( offset > offsetLeft + viewerSize.x - this.panelWidth ) {
|
|
|
|
offset = Math.min( offset, ( scrollWidth - viewerSize.x ) );
|
|
|
|
this.element.style.marginLeft = -offset + 'px';
|
|
|
|
loadPanels( this, viewerSize.x, -offset );
|
|
|
|
} else if ( offset < offsetLeft ) {
|
|
|
|
offset = Math.max( 0, offset - viewerSize.x / 2 );
|
|
|
|
this.element.style.marginLeft = -offset + 'px';
|
|
|
|
loadPanels( this, viewerSize.x, -offset );
|
2012-10-13 07:40:59 +04:00
|
|
|
}
|
2013-09-06 21:43:39 +04:00
|
|
|
} else {
|
|
|
|
offset = ( Number( page ) ) * ( this.panelHeight + 3 );
|
|
|
|
if ( offset > offsetTop + viewerSize.y - this.panelHeight ) {
|
|
|
|
offset = Math.min( offset, ( scrollHeight - viewerSize.y ) );
|
|
|
|
this.element.style.marginTop = -offset + 'px';
|
|
|
|
loadPanels( this, viewerSize.y, -offset );
|
|
|
|
} else if ( offset < offsetTop ) {
|
|
|
|
offset = Math.max( 0, offset - viewerSize.y / 2 );
|
|
|
|
this.element.style.marginTop = -offset + 'px';
|
|
|
|
loadPanels( this, viewerSize.y, -offset );
|
2012-10-13 07:40:59 +04:00
|
|
|
}
|
2013-09-06 04:20:17 +04:00
|
|
|
}
|
2013-09-06 21:43:39 +04:00
|
|
|
|
|
|
|
this.currentPage = page;
|
2020-08-13 07:22:48 +03:00
|
|
|
onStripEnter.call( this, { eventSource: this.tracker } );
|
2012-09-05 18:52:57 +04:00
|
|
|
}
|
2013-09-06 21:43:39 +04:00
|
|
|
},
|
2013-11-25 20:48:44 +04:00
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
/**
|
|
|
|
* @function
|
|
|
|
*/
|
|
|
|
update: function () {
|
|
|
|
if ( THIS[this.id].animating ) {
|
2021-12-15 09:24:11 +03:00
|
|
|
// $.console.log( 'image reference strip update' );
|
2013-09-06 21:43:39 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2014-11-18 01:03:14 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
destroy: function() {
|
2017-04-25 22:07:37 +03:00
|
|
|
if (this.miniViewers) {
|
|
|
|
for (var key in this.miniViewers) {
|
|
|
|
this.miniViewers[key].destroy();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
this.tracker.destroy();
|
|
|
|
|
2014-11-18 01:03:14 +03:00
|
|
|
if (this.element) {
|
2021-03-17 23:04:13 +03:00
|
|
|
this.viewer.removeControl( this.element );
|
2014-11-18 01:03:14 +03:00
|
|
|
}
|
2013-09-06 21:43:39 +04:00
|
|
|
}
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
};
|
|
|
|
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* @function
|
|
|
|
*/
|
|
|
|
function onStripClick( event ) {
|
|
|
|
if ( event.quick ) {
|
|
|
|
var page;
|
|
|
|
|
|
|
|
if ( 'horizontal' === this.scroll ) {
|
2023-01-26 13:44:39 +03:00
|
|
|
// +4px fix to solve problem with precision on thumbnail selection if there is a lot of them
|
2023-01-26 01:15:12 +03:00
|
|
|
page = Math.floor(event.position.x / (this.panelWidth + 4));
|
2020-08-13 07:22:48 +03:00
|
|
|
} else {
|
|
|
|
page = Math.floor(event.position.y / this.panelHeight);
|
|
|
|
}
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
this.viewer.goToPage( page );
|
|
|
|
}
|
2021-03-17 23:04:13 +03:00
|
|
|
|
|
|
|
this.element.focus();
|
2020-08-13 07:22:48 +03:00
|
|
|
}
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* @function
|
|
|
|
*/
|
2013-10-11 04:00:15 +04:00
|
|
|
function onStripDrag( event ) {
|
2013-09-06 21:43:39 +04:00
|
|
|
|
2020-08-13 07:22:48 +03:00
|
|
|
this.dragging = true;
|
|
|
|
if ( this.element ) {
|
|
|
|
var offsetLeft = Number( this.element.style.marginLeft.replace( 'px', '' ) ),
|
2013-09-10 01:27:58 +04:00
|
|
|
offsetTop = Number( this.element.style.marginTop.replace( 'px', '' ) ),
|
|
|
|
scrollWidth = Number( this.element.style.width.replace( 'px', '' ) ),
|
2013-09-06 22:10:05 +04:00
|
|
|
scrollHeight = Number( this.element.style.height.replace( 'px', '' ) ),
|
2013-09-10 01:27:58 +04:00
|
|
|
viewerSize = $.getElementSize( this.viewer.canvas );
|
2020-08-13 07:22:48 +03:00
|
|
|
|
2020-06-26 02:01:14 +03:00
|
|
|
if ( 'horizontal' === this.scroll ) {
|
2013-10-11 04:00:15 +04:00
|
|
|
if ( -event.delta.x > 0 ) {
|
2013-09-06 21:43:39 +04:00
|
|
|
//forward
|
|
|
|
if ( offsetLeft > -( scrollWidth - viewerSize.x ) ) {
|
2013-10-11 04:00:15 +04:00
|
|
|
this.element.style.marginLeft = ( offsetLeft + ( event.delta.x * 2 ) ) + 'px';
|
|
|
|
loadPanels( this, viewerSize.x, offsetLeft + ( event.delta.x * 2 ) );
|
2012-08-30 04:55:36 +04:00
|
|
|
}
|
2013-10-11 04:00:15 +04:00
|
|
|
} else if ( -event.delta.x < 0 ) {
|
2013-09-06 21:43:39 +04:00
|
|
|
//reverse
|
|
|
|
if ( offsetLeft < 0 ) {
|
2013-10-11 04:00:15 +04:00
|
|
|
this.element.style.marginLeft = ( offsetLeft + ( event.delta.x * 2 ) ) + 'px';
|
|
|
|
loadPanels( this, viewerSize.x, offsetLeft + ( event.delta.x * 2 ) );
|
2013-09-06 21:43:39 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2013-10-11 04:00:15 +04:00
|
|
|
if ( -event.delta.y > 0 ) {
|
2013-09-06 21:43:39 +04:00
|
|
|
//forward
|
|
|
|
if ( offsetTop > -( scrollHeight - viewerSize.y ) ) {
|
2013-10-11 04:00:15 +04:00
|
|
|
this.element.style.marginTop = ( offsetTop + ( event.delta.y * 2 ) ) + 'px';
|
|
|
|
loadPanels( this, viewerSize.y, offsetTop + ( event.delta.y * 2 ) );
|
2013-09-06 21:43:39 +04:00
|
|
|
}
|
2013-10-11 04:00:15 +04:00
|
|
|
} else if ( -event.delta.y < 0 ) {
|
2013-09-06 21:43:39 +04:00
|
|
|
//reverse
|
|
|
|
if ( offsetTop < 0 ) {
|
2013-10-11 04:00:15 +04:00
|
|
|
this.element.style.marginTop = ( offsetTop + ( event.delta.y * 2 ) ) + 'px';
|
|
|
|
loadPanels( this, viewerSize.y, offsetTop + ( event.delta.y * 2 ) );
|
2012-08-30 04:55:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-09-06 04:20:17 +04:00
|
|
|
}
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
}
|
2012-08-30 04:55:36 +04:00
|
|
|
|
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* @function
|
|
|
|
*/
|
2013-10-11 04:00:15 +04:00
|
|
|
function onStripScroll( event ) {
|
2020-08-13 07:22:48 +03:00
|
|
|
if ( this.element ) {
|
|
|
|
var offsetLeft = Number( this.element.style.marginLeft.replace( 'px', '' ) ),
|
2013-09-10 01:27:58 +04:00
|
|
|
offsetTop = Number( this.element.style.marginTop.replace( 'px', '' ) ),
|
|
|
|
scrollWidth = Number( this.element.style.width.replace( 'px', '' ) ),
|
2013-09-06 22:10:05 +04:00
|
|
|
scrollHeight = Number( this.element.style.height.replace( 'px', '' ) ),
|
2013-09-10 01:27:58 +04:00
|
|
|
viewerSize = $.getElementSize( this.viewer.canvas );
|
2020-08-13 07:22:48 +03:00
|
|
|
|
2020-06-26 02:01:14 +03:00
|
|
|
if ( 'horizontal' === this.scroll ) {
|
2013-10-11 04:00:15 +04:00
|
|
|
if ( event.scroll > 0 ) {
|
2013-09-06 21:43:39 +04:00
|
|
|
//forward
|
|
|
|
if ( offsetLeft > -( scrollWidth - viewerSize.x ) ) {
|
2013-10-11 04:00:15 +04:00
|
|
|
this.element.style.marginLeft = ( offsetLeft - ( event.scroll * 60 ) ) + 'px';
|
|
|
|
loadPanels( this, viewerSize.x, offsetLeft - ( event.scroll * 60 ) );
|
2012-08-30 04:55:36 +04:00
|
|
|
}
|
2013-10-11 04:00:15 +04:00
|
|
|
} else if ( event.scroll < 0 ) {
|
2013-09-06 21:43:39 +04:00
|
|
|
//reverse
|
|
|
|
if ( offsetLeft < 0 ) {
|
2013-10-11 04:00:15 +04:00
|
|
|
this.element.style.marginLeft = ( offsetLeft - ( event.scroll * 60 ) ) + 'px';
|
|
|
|
loadPanels( this, viewerSize.x, offsetLeft - ( event.scroll * 60 ) );
|
2013-09-06 21:43:39 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2013-10-11 04:00:15 +04:00
|
|
|
if ( event.scroll < 0 ) {
|
2013-09-06 21:43:39 +04:00
|
|
|
//scroll up
|
|
|
|
if ( offsetTop > viewerSize.y - scrollHeight ) {
|
2013-10-11 04:00:15 +04:00
|
|
|
this.element.style.marginTop = ( offsetTop + ( event.scroll * 60 ) ) + 'px';
|
|
|
|
loadPanels( this, viewerSize.y, offsetTop + ( event.scroll * 60 ) );
|
2013-09-06 21:43:39 +04:00
|
|
|
}
|
2013-10-11 04:00:15 +04:00
|
|
|
} else if ( event.scroll > 0 ) {
|
2013-09-06 21:43:39 +04:00
|
|
|
//scroll dowm
|
|
|
|
if ( offsetTop < 0 ) {
|
2013-10-11 04:00:15 +04:00
|
|
|
this.element.style.marginTop = ( offsetTop + ( event.scroll * 60 ) ) + 'px';
|
|
|
|
loadPanels( this, viewerSize.y, offsetTop + ( event.scroll * 60 ) );
|
2012-08-30 04:55:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-03-17 05:35:22 +03:00
|
|
|
|
|
|
|
event.preventDefault = true;
|
2012-08-30 04:55:36 +04:00
|
|
|
}
|
2013-09-06 21:43:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function loadPanels( strip, viewerSize, scroll ) {
|
|
|
|
var panelSize,
|
2013-09-06 22:10:05 +04:00
|
|
|
activePanelsStart,
|
|
|
|
activePanelsEnd,
|
|
|
|
miniViewer,
|
|
|
|
i,
|
|
|
|
element;
|
2020-06-26 02:01:14 +03:00
|
|
|
if ( 'horizontal' === strip.scroll ) {
|
2013-09-06 21:43:39 +04:00
|
|
|
panelSize = strip.panelWidth;
|
|
|
|
} else {
|
|
|
|
panelSize = strip.panelHeight;
|
|
|
|
}
|
|
|
|
activePanelsStart = Math.ceil( viewerSize / panelSize ) + 5;
|
|
|
|
activePanelsEnd = Math.ceil( ( Math.abs( scroll ) + viewerSize ) / panelSize ) + 1;
|
|
|
|
activePanelsStart = activePanelsEnd - activePanelsStart;
|
|
|
|
activePanelsStart = activePanelsStart < 0 ? 0 : activePanelsStart;
|
|
|
|
|
|
|
|
for ( i = activePanelsStart; i < activePanelsEnd && i < strip.panels.length; i++ ) {
|
|
|
|
element = strip.panels[i];
|
|
|
|
if ( !element.activePanel ) {
|
2017-07-06 22:59:26 +03:00
|
|
|
var miniTileSource;
|
|
|
|
var originalTileSource = strip.viewer.tileSources[i];
|
|
|
|
if (originalTileSource.referenceStripThumbnailUrl) {
|
|
|
|
miniTileSource = {
|
|
|
|
type: 'image',
|
|
|
|
url: originalTileSource.referenceStripThumbnailUrl
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
miniTileSource = originalTileSource;
|
|
|
|
}
|
2013-09-06 21:43:39 +04:00
|
|
|
miniViewer = new $.Viewer( {
|
2013-09-06 22:10:05 +04:00
|
|
|
id: element.id,
|
2017-07-06 22:59:26 +03:00
|
|
|
tileSources: [miniTileSource],
|
2013-09-06 22:10:05 +04:00
|
|
|
element: element,
|
|
|
|
navigatorSizeRatio: strip.sizeRatio,
|
|
|
|
showNavigator: false,
|
|
|
|
mouseNavEnabled: false,
|
|
|
|
showNavigationControl: false,
|
|
|
|
showSequenceControl: false,
|
|
|
|
immediateRender: true,
|
|
|
|
blendTime: 0,
|
2019-08-21 21:07:25 +03:00
|
|
|
animationTime: 0,
|
|
|
|
loadTilesWithAjax: strip.viewer.loadTilesWithAjax,
|
2019-11-20 04:05:03 +03:00
|
|
|
ajaxHeaders: strip.viewer.ajaxHeaders,
|
2023-12-21 23:29:25 +03:00
|
|
|
drawer: 'canvas', //always use canvas for the reference strip
|
2013-09-06 21:43:39 +04:00
|
|
|
} );
|
2020-08-13 07:22:48 +03:00
|
|
|
// Allow pointer events to pass through miniViewer's canvas/container
|
|
|
|
// elements so implicit pointer capture works on touch devices
|
|
|
|
$.setElementPointerEventsNone( miniViewer.canvas );
|
|
|
|
$.setElementPointerEventsNone( miniViewer.container );
|
|
|
|
// We'll use event delegation from the reference strip element instead of
|
|
|
|
// handling events on every miniViewer
|
|
|
|
miniViewer.innerTracker.setTracking( false );
|
|
|
|
miniViewer.outerTracker.setTracking( false );
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2017-04-25 22:07:37 +03:00
|
|
|
strip.miniViewers[element.id] = miniViewer;
|
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
element.activePanel = true;
|
2012-09-05 18:52:57 +04:00
|
|
|
}
|
|
|
|
}
|
2013-09-06 21:43:39 +04:00
|
|
|
}
|
2012-09-05 18:52:57 +04:00
|
|
|
|
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* @function
|
|
|
|
*/
|
2013-10-11 04:00:15 +04:00
|
|
|
function onStripEnter( event ) {
|
2013-10-11 21:44:03 +04:00
|
|
|
var element = event.eventSource.element;
|
2014-11-18 01:03:14 +03:00
|
|
|
|
2013-10-11 21:44:03 +04:00
|
|
|
//$.setElementOpacity(element, 0.8);
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2013-10-11 21:44:03 +04:00
|
|
|
//element.style.border = '1px solid #555';
|
|
|
|
//element.style.background = '#000';
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2020-06-26 02:01:14 +03:00
|
|
|
if ( 'horizontal' === this.scroll ) {
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2013-10-11 21:44:03 +04:00
|
|
|
//element.style.paddingTop = "0px";
|
|
|
|
element.style.marginBottom = "0px";
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
} else {
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2013-10-11 21:44:03 +04:00
|
|
|
//element.style.paddingRight = "0px";
|
|
|
|
element.style.marginLeft = "0px";
|
2012-08-30 04:55:36 +04:00
|
|
|
|
|
|
|
}
|
2013-09-06 21:43:39 +04:00
|
|
|
}
|
2012-08-30 04:55:36 +04:00
|
|
|
|
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* @function
|
|
|
|
*/
|
2020-07-25 06:05:39 +03:00
|
|
|
function onStripLeave( event ) {
|
2013-10-11 21:44:03 +04:00
|
|
|
var element = event.eventSource.element;
|
2014-11-18 01:03:14 +03:00
|
|
|
|
2020-06-26 02:01:14 +03:00
|
|
|
if ( 'horizontal' === this.scroll ) {
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2013-10-11 21:44:03 +04:00
|
|
|
//element.style.paddingTop = "10px";
|
|
|
|
element.style.marginBottom = "-" + ( $.getElementSize( element ).y / 2 ) + "px";
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
} else {
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2013-10-11 21:44:03 +04:00
|
|
|
//element.style.paddingRight = "10px";
|
|
|
|
element.style.marginLeft = "-" + ( $.getElementSize( element ).x / 2 ) + "px";
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-08-30 04:55:36 +04:00
|
|
|
}
|
2013-09-06 21:43:39 +04:00
|
|
|
}
|
2012-08-30 04:55:36 +04:00
|
|
|
|
2012-09-05 18:52:57 +04:00
|
|
|
|
2015-01-17 03:26:30 +03:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* @function
|
|
|
|
*/
|
|
|
|
function onKeyDown( event ) {
|
|
|
|
//console.log( event.keyCode );
|
|
|
|
|
2021-03-12 07:30:50 +03:00
|
|
|
if ( !event.ctrl && !event.alt && !event.meta ) {
|
2015-01-17 03:26:30 +03:00
|
|
|
switch ( event.keyCode ) {
|
|
|
|
case 38: //up arrow
|
|
|
|
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: 1, shift: null } );
|
2021-03-17 05:35:22 +03:00
|
|
|
event.preventDefault = true;
|
|
|
|
break;
|
2015-01-17 03:26:30 +03:00
|
|
|
case 40: //down arrow
|
|
|
|
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: -1, shift: null } );
|
2021-03-17 05:35:22 +03:00
|
|
|
event.preventDefault = true;
|
|
|
|
break;
|
2015-01-17 03:26:30 +03:00
|
|
|
case 37: //left arrow
|
|
|
|
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: -1, shift: null } );
|
2021-03-17 05:35:22 +03:00
|
|
|
event.preventDefault = true;
|
|
|
|
break;
|
2015-01-17 03:26:30 +03:00
|
|
|
case 39: //right arrow
|
|
|
|
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: 1, shift: null } );
|
2021-03-17 05:35:22 +03:00
|
|
|
event.preventDefault = true;
|
|
|
|
break;
|
2015-01-17 03:26:30 +03:00
|
|
|
default:
|
|
|
|
//console.log( 'navigator keycode %s', event.keyCode );
|
2021-03-17 05:35:22 +03:00
|
|
|
event.preventDefault = false;
|
|
|
|
break;
|
2015-01-17 03:26:30 +03:00
|
|
|
}
|
|
|
|
} else {
|
2021-03-17 05:35:22 +03:00
|
|
|
event.preventDefault = false;
|
2015-01-17 03:26:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-05 18:52:57 +04:00
|
|
|
|
2013-09-06 21:43:39 +04:00
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
|
|
|
* @function
|
|
|
|
*/
|
2013-10-11 04:00:15 +04:00
|
|
|
function onKeyPress( event ) {
|
|
|
|
//console.log( event.keyCode );
|
2013-09-06 21:43:39 +04:00
|
|
|
|
2021-03-12 07:30:50 +03:00
|
|
|
if ( !event.ctrl && !event.alt && !event.meta ) {
|
2015-01-17 03:26:30 +03:00
|
|
|
switch ( event.keyCode ) {
|
|
|
|
case 61: //=|+
|
|
|
|
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: 1, shift: null } );
|
2021-03-17 05:35:22 +03:00
|
|
|
event.preventDefault = true;
|
|
|
|
break;
|
2015-01-17 03:26:30 +03:00
|
|
|
case 45: //-|_
|
|
|
|
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: -1, shift: null } );
|
2021-03-17 05:35:22 +03:00
|
|
|
event.preventDefault = true;
|
|
|
|
break;
|
2015-01-17 03:26:30 +03:00
|
|
|
case 48: //0|)
|
|
|
|
case 119: //w
|
|
|
|
case 87: //W
|
|
|
|
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: 1, shift: null } );
|
2021-03-17 05:35:22 +03:00
|
|
|
event.preventDefault = true;
|
|
|
|
break;
|
2015-01-17 03:26:30 +03:00
|
|
|
case 115: //s
|
|
|
|
case 83: //S
|
|
|
|
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: -1, shift: null } );
|
2021-03-17 05:35:22 +03:00
|
|
|
event.preventDefault = true;
|
|
|
|
break;
|
2015-01-17 03:26:30 +03:00
|
|
|
case 97: //a
|
|
|
|
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: -1, shift: null } );
|
2021-03-17 05:35:22 +03:00
|
|
|
event.preventDefault = true;
|
|
|
|
break;
|
2015-01-17 03:26:30 +03:00
|
|
|
case 100: //d
|
|
|
|
onStripScroll.call( this, { eventSource: this.tracker, position: null, scroll: 1, shift: null } );
|
2021-03-17 05:35:22 +03:00
|
|
|
event.preventDefault = true;
|
|
|
|
break;
|
2015-01-17 03:26:30 +03:00
|
|
|
default:
|
|
|
|
//console.log( 'navigator keycode %s', event.keyCode );
|
2021-03-17 05:35:22 +03:00
|
|
|
event.preventDefault = false;
|
|
|
|
break;
|
2015-01-17 03:26:30 +03:00
|
|
|
}
|
|
|
|
} else {
|
2021-03-17 05:35:22 +03:00
|
|
|
event.preventDefault = false;
|
2012-09-05 18:52:57 +04:00
|
|
|
}
|
2013-09-06 21:43:39 +04:00
|
|
|
}
|
2012-09-05 18:52:57 +04:00
|
|
|
|
2017-01-08 17:52:57 +03:00
|
|
|
}(OpenSeadragon));
|