2013-05-01 08:46:16 +04:00
|
|
|
/*
|
2013-05-14 08:00:24 +04:00
|
|
|
* OpenSeadragon - Viewer
|
2013-05-01 08:46:16 +04:00
|
|
|
*
|
|
|
|
* Copyright (C) 2009 CodePlex Foundation
|
2013-05-14 07:32:09 +04:00
|
|
|
* Copyright (C) 2010-2013 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.
|
|
|
|
*
|
2013-10-10 02:31:33 +04:00
|
|
|
* - Redistributions in binary form must reproduce the above copyright
|
2013-05-01 08:46:16 +04:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2011-12-06 07:50:25 +04:00
|
|
|
(function( $ ){
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-02-27 15:56:29 +04:00
|
|
|
// dictionary from hash to private properties
|
2014-10-30 02:11:21 +03:00
|
|
|
var THIS = {};
|
2015-01-03 01:24:05 +03:00
|
|
|
var nextHash = 1;
|
2012-02-27 15:56:29 +04:00
|
|
|
|
2011-12-07 05:26:06 +04:00
|
|
|
/**
|
|
|
|
*
|
2016-04-09 17:15:02 +03:00
|
|
|
* The main point of entry into creating a zoomable image on the page.<br>
|
|
|
|
* <br>
|
2012-02-01 00:59:09 +04:00
|
|
|
* We have provided an idiomatic javascript constructor which takes
|
2016-04-09 17:15:02 +03:00
|
|
|
* a single object, but still support the legacy positional arguments.<br>
|
|
|
|
* <br>
|
2012-02-01 00:59:09 +04:00
|
|
|
* The options below are given in order that they appeared in the constructor
|
2016-04-09 17:15:02 +03:00
|
|
|
* as arguments and we translate a positional call into an idiomatic call.<br>
|
|
|
|
* <br>
|
|
|
|
* To create a viewer, you can use either of this methods:<br>
|
|
|
|
* <ul>
|
|
|
|
* <li><code>var viewer = new OpenSeadragon.Viewer(options);</code></li>
|
|
|
|
* <li><code>var viewer = OpenSeadragon(options);</code></li>
|
|
|
|
* </ul>
|
2013-11-16 10:19:53 +04:00
|
|
|
* @class Viewer
|
2013-11-25 20:48:44 +04:00
|
|
|
* @classdesc The main OpenSeadragon viewer class.
|
|
|
|
*
|
2013-11-16 10:19:53 +04:00
|
|
|
* @memberof OpenSeadragon
|
2013-09-25 00:36:13 +04:00
|
|
|
* @extends OpenSeadragon.EventSource
|
2012-03-09 20:04:28 +04:00
|
|
|
* @extends OpenSeadragon.ControlDock
|
2013-11-19 23:20:45 +04:00
|
|
|
* @param {OpenSeadragon.Options} options - Viewer options.
|
2011-12-07 05:26:06 +04:00
|
|
|
*
|
2013-06-19 21:33:25 +04:00
|
|
|
**/
|
2011-12-07 05:26:06 +04:00
|
|
|
$.Viewer = function( options ) {
|
|
|
|
|
2012-01-24 17:03:50 +04:00
|
|
|
var args = arguments,
|
2011-12-08 06:10:13 +04:00
|
|
|
_this = this,
|
|
|
|
i;
|
2011-12-07 05:26:06 +04:00
|
|
|
|
2011-12-15 03:22:02 +04:00
|
|
|
|
2013-06-19 21:33:25 +04:00
|
|
|
//backward compatibility for positional args while prefering more
|
2012-03-01 17:38:15 +04:00
|
|
|
//idiomatic javascript options object as the only argument
|
2012-02-28 03:29:00 +04:00
|
|
|
if( !$.isPlainObject( options ) ){
|
2011-12-07 05:26:06 +04:00
|
|
|
options = {
|
|
|
|
id: args[ 0 ],
|
|
|
|
xmlPath: args.length > 1 ? args[ 1 ] : undefined,
|
|
|
|
prefixUrl: args.length > 2 ? args[ 2 ] : undefined,
|
|
|
|
controls: args.length > 3 ? args[ 3 ] : undefined,
|
2014-01-30 01:31:13 +04:00
|
|
|
overlays: args.length > 4 ? args[ 4 ] : undefined
|
2011-12-07 05:26:06 +04:00
|
|
|
};
|
|
|
|
}
|
2012-03-01 17:38:15 +04:00
|
|
|
|
|
|
|
//options.config and the general config argument are deprecated
|
|
|
|
//in favor of the more direct specification of optional settings
|
|
|
|
//being pass directly on the options object
|
|
|
|
if ( options.config ){
|
|
|
|
$.extend( true, options, options.config );
|
|
|
|
delete options.config;
|
|
|
|
}
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-04-03 11:08:27 +04:00
|
|
|
//Public properties
|
2011-12-07 05:26:06 +04:00
|
|
|
//Allow the options object to override global defaults
|
2013-06-19 21:33:25 +04:00
|
|
|
$.extend( true, this, {
|
2012-03-01 17:38:15 +04:00
|
|
|
|
2012-04-03 11:08:27 +04:00
|
|
|
//internal state and dom identifiers
|
|
|
|
id: options.id,
|
2015-01-03 01:24:05 +03:00
|
|
|
hash: options.hash || nextHash++,
|
2017-05-14 16:56:21 +03:00
|
|
|
/**
|
2017-05-15 20:13:34 +03:00
|
|
|
* Index for page to be shown first next time open() is called (only used in sequenceMode).
|
2017-05-14 16:56:21 +03:00
|
|
|
* @member {Number} initialPage
|
|
|
|
* @memberof OpenSeadragon.Viewer#
|
|
|
|
*/
|
|
|
|
initialPage: 0,
|
2012-04-03 11:08:27 +04:00
|
|
|
|
|
|
|
//dom nodes
|
2013-11-25 20:48:44 +04:00
|
|
|
/**
|
|
|
|
* The parent element of this Viewer instance, passed in when the Viewer was created.
|
|
|
|
* @member {Element} element
|
|
|
|
* @memberof OpenSeadragon.Viewer#
|
|
|
|
*/
|
2012-04-03 11:08:27 +04:00
|
|
|
element: null,
|
2013-11-25 20:48:44 +04:00
|
|
|
/**
|
2014-04-05 00:14:32 +04:00
|
|
|
* A <div> element (provided by {@link OpenSeadragon.ControlDock}), the base element of this Viewer instance.<br><br>
|
2013-11-25 20:48:44 +04:00
|
|
|
* Child element of {@link OpenSeadragon.Viewer#element}.
|
|
|
|
* @member {Element} container
|
|
|
|
* @memberof OpenSeadragon.Viewer#
|
|
|
|
*/
|
2012-04-03 11:08:27 +04:00
|
|
|
container: null,
|
2013-11-25 20:48:44 +04:00
|
|
|
/**
|
|
|
|
* A <div> element, the element where user-input events are handled for panning and zooming.<br><br>
|
|
|
|
* Child element of {@link OpenSeadragon.Viewer#container},
|
|
|
|
* positioned on top of {@link OpenSeadragon.Viewer#keyboardCommandArea}.<br><br>
|
2014-07-18 03:24:28 +04:00
|
|
|
* The parent of {@link OpenSeadragon.Drawer#canvas} instances.
|
2013-11-25 20:48:44 +04:00
|
|
|
* @member {Element} canvas
|
|
|
|
* @memberof OpenSeadragon.Viewer#
|
|
|
|
*/
|
|
|
|
canvas: null,
|
2012-04-03 11:08:27 +04:00
|
|
|
|
2014-01-31 00:38:37 +04:00
|
|
|
// Overlays list. An overlay allows to add html on top of the viewer.
|
2014-01-31 20:49:44 +04:00
|
|
|
overlays: [],
|
2014-03-20 17:56:12 +04:00
|
|
|
// Container inside the canvas where overlays are drawn.
|
|
|
|
overlaysContainer: null,
|
2011-12-08 06:10:13 +04:00
|
|
|
|
2012-03-01 17:38:15 +04:00
|
|
|
//private state properties
|
2012-04-03 11:08:27 +04:00
|
|
|
previousBody: [],
|
2011-12-08 06:10:13 +04:00
|
|
|
|
|
|
|
//This was originally initialized in the constructor and so could never
|
|
|
|
//have anything in it. now it can because we allow it to be specified
|
|
|
|
//in the options and is only empty by default if not specified. Also
|
|
|
|
//this array was returned from get_controls which I find confusing
|
|
|
|
//since this object has a controls property which is treated in other
|
|
|
|
//functions like clearControls. I'm removing the accessors.
|
2012-03-01 17:38:15 +04:00
|
|
|
customControls: [],
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2012-03-01 17:38:15 +04:00
|
|
|
//These are originally not part options but declared as members
|
2013-11-19 23:20:45 +04:00
|
|
|
//in initialize. It's still considered idiomatic to put them here
|
2018-06-14 23:50:45 +03:00
|
|
|
//source is here for backwards compatibility. It is not an official
|
|
|
|
//part of the API and should not be relied upon.
|
2012-03-01 17:38:15 +04:00
|
|
|
source: null,
|
2013-11-19 22:08:04 +04:00
|
|
|
/**
|
2013-11-25 20:48:44 +04:00
|
|
|
* Handles rendering of tiles in the viewer. Created for each TileSource opened.
|
2013-11-19 22:08:04 +04:00
|
|
|
* @member {OpenSeadragon.Drawer} drawer
|
|
|
|
* @memberof OpenSeadragon.Viewer#
|
|
|
|
*/
|
2014-03-20 17:56:12 +04:00
|
|
|
drawer: null,
|
2018-06-13 14:32:10 +03:00
|
|
|
/**
|
|
|
|
* Keeps track of all of the tiled images in the scene.
|
|
|
|
* @member {OpenSeadragon.Drawer} world
|
|
|
|
* @memberof OpenSeadragon.Viewer#
|
|
|
|
*/
|
2014-08-07 00:48:18 +04:00
|
|
|
world: null,
|
2013-11-19 22:08:04 +04:00
|
|
|
/**
|
2013-11-25 20:48:44 +04:00
|
|
|
* Handles coordinate-related functionality - zoom, pan, rotation, etc. Created for each TileSource opened.
|
2013-11-19 22:08:04 +04:00
|
|
|
* @member {OpenSeadragon.Viewport} viewport
|
|
|
|
* @memberof OpenSeadragon.Viewer#
|
|
|
|
*/
|
2012-03-01 17:38:15 +04:00
|
|
|
viewport: null,
|
2013-11-19 22:08:04 +04:00
|
|
|
/**
|
|
|
|
* @member {OpenSeadragon.Navigator} navigator
|
|
|
|
* @memberof OpenSeadragon.Viewer#
|
|
|
|
*/
|
2013-06-19 21:33:25 +04:00
|
|
|
navigator: null,
|
2012-04-03 11:08:27 +04:00
|
|
|
|
2013-11-19 22:08:04 +04:00
|
|
|
//A collection viewport is a separate viewport used to provide
|
2013-11-19 23:20:45 +04:00
|
|
|
//simultaneous rendering of sets of tiles
|
2013-01-24 08:00:11 +04:00
|
|
|
collectionViewport: null,
|
|
|
|
collectionDrawer: null,
|
|
|
|
|
2012-04-03 11:08:27 +04:00
|
|
|
//UI image resources
|
|
|
|
//TODO: rename navImages to uiImages
|
|
|
|
navImages: null,
|
|
|
|
|
|
|
|
//interface button controls
|
2013-06-19 21:33:25 +04:00
|
|
|
buttons: null,
|
2012-04-03 11:08:27 +04:00
|
|
|
|
|
|
|
//TODO: this is defunct so safely remove it
|
2012-03-01 17:38:15 +04:00
|
|
|
profiler: null
|
2011-12-07 05:26:06 +04:00
|
|
|
|
2012-03-01 17:38:15 +04:00
|
|
|
}, $.DEFAULT_SETTINGS, options );
|
|
|
|
|
2018-05-11 20:53:16 +03:00
|
|
|
if ( typeof ( this.hash) === "undefined" ) {
|
2013-10-13 02:30:05 +04:00
|
|
|
throw new Error("A hash must be defined, either by specifying options.id or options.hash.");
|
|
|
|
}
|
2018-05-11 20:53:16 +03:00
|
|
|
if ( typeof ( THIS[ this.hash ] ) !== "undefined" ) {
|
2013-10-13 02:30:05 +04:00
|
|
|
// We don't want to throw an error here, as the user might have discarded
|
|
|
|
// the previous viewer with the same hash and now want to recreate it.
|
|
|
|
$.console.warn("Hash " + this.hash + " has already been used.");
|
|
|
|
}
|
|
|
|
|
2012-04-03 11:08:27 +04:00
|
|
|
//Private state properties
|
|
|
|
THIS[ this.hash ] = {
|
|
|
|
"fsBoundsDelta": new $.Point( 1, 1 ),
|
|
|
|
"prevContainerSize": null,
|
|
|
|
"animating": false,
|
|
|
|
"forceRedraw": false,
|
|
|
|
"mouseInside": false,
|
|
|
|
"group": null,
|
|
|
|
// whether we should be continuously zooming
|
|
|
|
"zooming": false,
|
|
|
|
// how much we should be continuously zooming by
|
2013-06-19 21:33:25 +04:00
|
|
|
"zoomFactor": null,
|
2012-04-03 11:08:27 +04:00
|
|
|
"lastZoomTime": null,
|
2013-06-19 21:33:25 +04:00
|
|
|
"fullPage": false,
|
2013-02-28 23:28:05 +04:00
|
|
|
"onfullscreenchange": null
|
2012-04-03 11:08:27 +04:00
|
|
|
};
|
|
|
|
|
2014-11-15 04:19:04 +03:00
|
|
|
this._sequenceIndex = 0;
|
2014-11-15 03:51:02 +03:00
|
|
|
this._firstOpen = true;
|
2013-06-18 22:06:43 +04:00
|
|
|
this._updateRequestId = null;
|
2014-11-19 02:45:03 +03:00
|
|
|
this._loadQueue = [];
|
2014-03-15 19:20:33 +04:00
|
|
|
this.currentOverlays = [];
|
2013-06-18 22:06:43 +04:00
|
|
|
|
2015-10-29 02:07:51 +03:00
|
|
|
this._lastScrollTime = $.now(); // variable used to help normalize the scroll event speed of different devices
|
|
|
|
|
2012-04-03 11:08:27 +04:00
|
|
|
//Inherit some behaviors and properties
|
2013-09-25 00:36:13 +04:00
|
|
|
$.EventSource.call( this );
|
2013-06-28 02:10:23 +04:00
|
|
|
|
2013-10-11 04:00:15 +04:00
|
|
|
this.addHandler( 'open-failed', function ( event ) {
|
|
|
|
var msg = $.getString( "Errors.OpenFailed", event.eventSource, event.message);
|
2013-07-01 21:43:48 +04:00
|
|
|
_this._showMessage( msg );
|
2013-06-28 02:10:23 +04:00
|
|
|
});
|
|
|
|
|
2012-03-09 20:04:28 +04:00
|
|
|
$.ControlDock.call( this, options );
|
|
|
|
|
2012-04-03 11:08:27 +04:00
|
|
|
//Deal with tile sources
|
2017-01-08 17:52:57 +03:00
|
|
|
if (this.xmlPath) {
|
2012-04-03 11:08:27 +04:00
|
|
|
//Deprecated option. Now it is preferred to use the tileSources option
|
|
|
|
this.tileSources = [ this.xmlPath ];
|
|
|
|
}
|
|
|
|
|
2013-04-05 06:30:59 +04:00
|
|
|
this.element = this.element || document.getElementById( this.id );
|
|
|
|
this.canvas = $.makeNeutralElement( "div" );
|
2012-01-24 17:03:50 +04:00
|
|
|
|
2013-02-14 01:50:23 +04:00
|
|
|
this.canvas.className = "openseadragon-canvas";
|
2013-03-17 00:35:33 +04:00
|
|
|
(function( style ){
|
|
|
|
style.width = "100%";
|
|
|
|
style.height = "100%";
|
|
|
|
style.overflow = "hidden";
|
|
|
|
style.position = "absolute";
|
|
|
|
style.top = "0px";
|
|
|
|
style.left = "0px";
|
2014-03-10 22:49:51 +04:00
|
|
|
}(this.canvas.style));
|
2014-08-06 03:57:54 +04:00
|
|
|
$.setElementTouchActionNone( this.canvas );
|
2016-03-08 20:58:50 +03:00
|
|
|
if (options.tabIndex !== "") {
|
|
|
|
this.canvas.tabIndex = (options.tabIndex === undefined ? 0 : options.tabIndex);
|
|
|
|
}
|
2012-03-09 20:04:28 +04:00
|
|
|
|
2013-02-14 01:50:23 +04:00
|
|
|
//the container is created through applying the ControlDock constructor above
|
|
|
|
this.container.className = "openseadragon-container";
|
2013-03-17 00:35:33 +04:00
|
|
|
(function( style ){
|
|
|
|
style.width = "100%";
|
|
|
|
style.height = "100%";
|
|
|
|
style.position = "relative";
|
|
|
|
style.overflow = "hidden";
|
|
|
|
style.left = "0px";
|
|
|
|
style.top = "0px";
|
|
|
|
style.textAlign = "left"; // needed to protect against
|
2012-03-09 20:04:28 +04:00
|
|
|
}( this.container.style ));
|
|
|
|
|
2012-04-03 11:08:27 +04:00
|
|
|
this.container.insertBefore( this.canvas, this.container.firstChild );
|
2012-03-09 20:04:28 +04:00
|
|
|
this.element.appendChild( this.container );
|
|
|
|
|
2012-01-24 17:03:50 +04:00
|
|
|
//Used for toggling between fullscreen and default container size
|
2012-02-27 15:56:29 +04:00
|
|
|
//TODO: these can be closure private and shared across Viewer
|
|
|
|
// instances.
|
2012-01-24 17:03:50 +04:00
|
|
|
this.bodyWidth = document.body.style.width;
|
|
|
|
this.bodyHeight = document.body.style.height;
|
|
|
|
this.bodyOverflow = document.body.style.overflow;
|
|
|
|
this.docOverflow = document.documentElement.style.overflow;
|
2012-02-27 15:56:29 +04:00
|
|
|
|
2012-02-03 04:12:45 +04:00
|
|
|
this.innerTracker = new $.MouseTracker({
|
2015-01-12 22:02:54 +03:00
|
|
|
element: this.canvas,
|
2017-01-08 17:52:57 +03:00
|
|
|
startDisabled: !this.mouseNavEnabled,
|
2015-01-12 22:02:54 +03:00
|
|
|
clickTimeThreshold: this.clickTimeThreshold,
|
|
|
|
clickDistThreshold: this.clickDistThreshold,
|
|
|
|
dblClickTimeThreshold: this.dblClickTimeThreshold,
|
|
|
|
dblClickDistThreshold: this.dblClickDistThreshold,
|
2015-01-17 22:18:55 +03:00
|
|
|
keyDownHandler: $.delegate( this, onCanvasKeyDown ),
|
|
|
|
keyHandler: $.delegate( this, onCanvasKeyPress ),
|
2015-01-12 22:02:54 +03:00
|
|
|
clickHandler: $.delegate( this, onCanvasClick ),
|
|
|
|
dblClickHandler: $.delegate( this, onCanvasDblClick ),
|
|
|
|
dragHandler: $.delegate( this, onCanvasDrag ),
|
|
|
|
dragEndHandler: $.delegate( this, onCanvasDragEnd ),
|
2015-01-15 23:15:22 +03:00
|
|
|
enterHandler: $.delegate( this, onCanvasEnter ),
|
|
|
|
exitHandler: $.delegate( this, onCanvasExit ),
|
|
|
|
pressHandler: $.delegate( this, onCanvasPress ),
|
2015-01-12 22:02:54 +03:00
|
|
|
releaseHandler: $.delegate( this, onCanvasRelease ),
|
|
|
|
nonPrimaryPressHandler: $.delegate( this, onCanvasNonPrimaryPress ),
|
|
|
|
nonPrimaryReleaseHandler: $.delegate( this, onCanvasNonPrimaryRelease ),
|
|
|
|
scrollHandler: $.delegate( this, onCanvasScroll ),
|
|
|
|
pinchHandler: $.delegate( this, onCanvasPinch )
|
2015-01-21 05:35:58 +03:00
|
|
|
});
|
2011-12-08 06:10:13 +04:00
|
|
|
|
2012-02-03 04:12:45 +04:00
|
|
|
this.outerTracker = new $.MouseTracker({
|
2014-04-22 20:23:56 +04:00
|
|
|
element: this.container,
|
2017-01-08 17:52:57 +03:00
|
|
|
startDisabled: !this.mouseNavEnabled,
|
2014-04-22 20:23:56 +04:00
|
|
|
clickTimeThreshold: this.clickTimeThreshold,
|
|
|
|
clickDistThreshold: this.clickDistThreshold,
|
|
|
|
dblClickTimeThreshold: this.dblClickTimeThreshold,
|
|
|
|
dblClickDistThreshold: this.dblClickDistThreshold,
|
|
|
|
enterHandler: $.delegate( this, onContainerEnter ),
|
2015-01-15 23:15:22 +03:00
|
|
|
exitHandler: $.delegate( this, onContainerExit )
|
2015-01-21 05:35:58 +03:00
|
|
|
});
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-04-11 01:02:24 +04:00
|
|
|
if( this.toolbar ){
|
|
|
|
this.toolbar = new $.ControlDock({ element: this.toolbar });
|
2011-12-07 05:26:06 +04:00
|
|
|
}
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-04-11 01:02:24 +04:00
|
|
|
this.bindStandardControls();
|
2011-12-08 06:10:13 +04:00
|
|
|
|
2014-10-30 02:11:21 +03:00
|
|
|
THIS[ this.hash ].prevContainerSize = _getSafeElemSize( this.container );
|
|
|
|
|
|
|
|
// Create the world
|
2014-09-25 00:58:09 +04:00
|
|
|
this.world = new $.World({
|
|
|
|
viewer: this
|
|
|
|
});
|
|
|
|
|
|
|
|
this.world.addHandler('add-item', function(event) {
|
2014-10-30 02:11:21 +03:00
|
|
|
// For backwards compatibility, we maintain the source property
|
|
|
|
_this.source = _this.world.getItemAt(0).source;
|
|
|
|
|
2014-09-25 00:58:09 +04:00
|
|
|
THIS[ _this.hash ].forceRedraw = true;
|
2014-10-30 02:11:21 +03:00
|
|
|
|
|
|
|
if (!_this._updateRequestId) {
|
|
|
|
_this._updateRequestId = scheduleUpdate( _this, updateMulti );
|
|
|
|
}
|
2014-09-25 00:58:09 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
this.world.addHandler('remove-item', function(event) {
|
2014-10-30 02:11:21 +03:00
|
|
|
// For backwards compatibility, we maintain the source property
|
|
|
|
if (_this.world.getItemCount()) {
|
|
|
|
_this.source = _this.world.getItemAt(0).source;
|
|
|
|
} else {
|
|
|
|
_this.source = null;
|
|
|
|
}
|
|
|
|
|
2014-09-25 00:58:09 +04:00
|
|
|
THIS[ _this.hash ].forceRedraw = true;
|
|
|
|
});
|
|
|
|
|
2014-11-15 02:49:42 +03:00
|
|
|
this.world.addHandler('metrics-change', function(event) {
|
2014-11-12 04:14:48 +03:00
|
|
|
if (_this.viewport) {
|
2016-02-12 04:14:49 +03:00
|
|
|
_this.viewport._setContentBounds(_this.world.getHomeBounds(), _this.world.getContentFactor());
|
2014-11-12 04:14:48 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-11-13 03:31:46 +03:00
|
|
|
this.world.addHandler('item-index-change', function(event) {
|
2014-10-30 02:11:21 +03:00
|
|
|
// For backwards compatibility, we maintain the source property
|
|
|
|
_this.source = _this.world.getItemAt(0).source;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Create the viewport
|
|
|
|
this.viewport = new $.Viewport({
|
|
|
|
containerSize: THIS[ this.hash ].prevContainerSize,
|
|
|
|
springStiffness: this.springStiffness,
|
|
|
|
animationTime: this.animationTime,
|
|
|
|
minZoomImageRatio: this.minZoomImageRatio,
|
|
|
|
maxZoomPixelRatio: this.maxZoomPixelRatio,
|
|
|
|
visibilityRatio: this.visibilityRatio,
|
|
|
|
wrapHorizontal: this.wrapHorizontal,
|
|
|
|
wrapVertical: this.wrapVertical,
|
|
|
|
defaultZoomLevel: this.defaultZoomLevel,
|
|
|
|
minZoomLevel: this.minZoomLevel,
|
|
|
|
maxZoomLevel: this.maxZoomLevel,
|
|
|
|
viewer: this,
|
|
|
|
degrees: this.degrees,
|
2018-04-11 20:24:01 +03:00
|
|
|
flipped: this.flipped,
|
2014-10-30 02:11:21 +03:00
|
|
|
navigatorRotate: this.navigatorRotate,
|
2014-11-04 20:58:09 +03:00
|
|
|
homeFillsViewer: this.homeFillsViewer,
|
|
|
|
margins: this.viewportMargins
|
2014-10-30 02:11:21 +03:00
|
|
|
});
|
|
|
|
|
2016-02-12 04:14:49 +03:00
|
|
|
this.viewport._setContentBounds(this.world.getHomeBounds(), this.world.getContentFactor());
|
2014-11-15 02:49:42 +03:00
|
|
|
|
2014-10-30 02:11:21 +03:00
|
|
|
// Create the image loader
|
2014-12-19 17:17:15 +03:00
|
|
|
this.imageLoader = new $.ImageLoader({
|
2017-05-12 07:36:27 +03:00
|
|
|
jobLimit: this.imageLoaderLimit,
|
|
|
|
timeout: options.timeout
|
2014-12-19 17:17:15 +03:00
|
|
|
});
|
2014-10-30 02:11:21 +03:00
|
|
|
|
|
|
|
// Create the tile cache
|
|
|
|
this.tileCache = new $.TileCache({
|
|
|
|
maxImageCacheCount: this.maxImageCacheCount
|
|
|
|
});
|
|
|
|
|
|
|
|
// Create the drawer
|
|
|
|
this.drawer = new $.Drawer({
|
|
|
|
viewer: this,
|
|
|
|
viewport: this.viewport,
|
|
|
|
element: this.canvas,
|
|
|
|
debugGridColor: this.debugGridColor
|
|
|
|
});
|
|
|
|
|
2014-11-21 01:50:07 +03:00
|
|
|
// Overlay container
|
|
|
|
this.overlaysContainer = $.makeNeutralElement( "div" );
|
|
|
|
this.canvas.appendChild( this.overlaysContainer );
|
|
|
|
|
2014-10-30 02:11:21 +03:00
|
|
|
// Now that we have a drawer, see if it supports rotate. If not we need to remove the rotate buttons
|
|
|
|
if (!this.drawer.canRotate()) {
|
|
|
|
// Disable/remove the rotate left/right buttons since they aren't supported
|
|
|
|
if (this.rotateLeft) {
|
|
|
|
i = this.buttons.buttons.indexOf(this.rotateLeft);
|
|
|
|
this.buttons.buttons.splice(i, 1);
|
|
|
|
this.buttons.element.removeChild(this.rotateLeft.element);
|
|
|
|
}
|
|
|
|
if (this.rotateRight) {
|
|
|
|
i = this.buttons.buttons.indexOf(this.rotateRight);
|
|
|
|
this.buttons.buttons.splice(i, 1);
|
|
|
|
this.buttons.element.removeChild(this.rotateRight.element);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Instantiate a navigator if configured
|
|
|
|
if ( this.showNavigator){
|
|
|
|
this.navigator = new $.Navigator({
|
|
|
|
id: this.navigatorId,
|
|
|
|
position: this.navigatorPosition,
|
|
|
|
sizeRatio: this.navigatorSizeRatio,
|
|
|
|
maintainSizeRatio: this.navigatorMaintainSizeRatio,
|
|
|
|
top: this.navigatorTop,
|
|
|
|
left: this.navigatorLeft,
|
|
|
|
width: this.navigatorWidth,
|
|
|
|
height: this.navigatorHeight,
|
|
|
|
autoResize: this.navigatorAutoResize,
|
2016-05-06 04:00:01 +03:00
|
|
|
autoFade: this.navigatorAutoFade,
|
2014-10-30 02:11:21 +03:00
|
|
|
prefixUrl: this.prefixUrl,
|
|
|
|
viewer: this,
|
2015-02-27 01:57:31 +03:00
|
|
|
navigatorRotate: this.navigatorRotate,
|
2018-06-14 19:38:30 +03:00
|
|
|
background: this.navigatorBackground,
|
|
|
|
opacity: this.navigatorOpacity,
|
|
|
|
borderColor: this.navigatorBorderColor,
|
|
|
|
displayRegionColor: this.navigatorDisplayRegionColor,
|
2015-02-27 01:57:31 +03:00
|
|
|
crossOriginPolicy: this.crossOriginPolicy
|
2014-10-30 02:11:21 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-11-15 03:51:02 +03:00
|
|
|
// Sequence mode
|
|
|
|
if (this.sequenceMode) {
|
|
|
|
this.bindSequenceControls();
|
|
|
|
}
|
|
|
|
|
2014-10-30 02:11:21 +03:00
|
|
|
// Open initial tilesources
|
2014-12-20 02:32:19 +03:00
|
|
|
if (this.tileSources) {
|
2014-11-18 01:03:14 +03:00
|
|
|
this.open( this.tileSources );
|
2013-10-10 23:25:11 +04:00
|
|
|
}
|
2013-10-10 23:57:02 +04:00
|
|
|
|
2014-10-30 02:11:21 +03:00
|
|
|
// Add custom controls
|
2012-03-16 19:36:28 +04:00
|
|
|
for ( i = 0; i < this.customControls.length; i++ ) {
|
|
|
|
this.addControl(
|
2013-06-19 21:33:25 +04:00
|
|
|
this.customControls[ i ].id,
|
2013-03-15 18:59:47 +04:00
|
|
|
{anchor: this.customControls[ i ].anchor}
|
2012-03-16 19:36:28 +04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-10-30 02:11:21 +03:00
|
|
|
// Initial fade out
|
2013-02-26 19:19:48 +04:00
|
|
|
$.requestAnimationFrame( function(){
|
2011-12-08 06:10:13 +04:00
|
|
|
beginControlsAutoHide( _this );
|
2014-10-30 02:11:21 +03:00
|
|
|
} );
|
2018-08-04 01:47:16 +03:00
|
|
|
|
|
|
|
// Initial canvas options
|
|
|
|
if ( this.imageSmoothingEnabled !== undefined && !this.imageSmoothingEnabled){
|
|
|
|
this.drawer.setImageSmoothingEnabled(this.imageSmoothingEnabled);
|
|
|
|
}
|
|
|
|
|
2011-12-06 07:50:25 +04:00
|
|
|
};
|
|
|
|
|
2013-11-16 10:19:53 +04:00
|
|
|
$.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, /** @lends OpenSeadragon.Viewer.prototype */{
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2011-12-23 05:47:21 +04:00
|
|
|
|
2012-02-01 00:59:09 +04:00
|
|
|
/**
|
|
|
|
* @function
|
2012-02-18 22:13:05 +04:00
|
|
|
* @return {Boolean}
|
2012-02-01 00:59:09 +04:00
|
|
|
*/
|
2011-12-06 07:50:25 +04:00
|
|
|
isOpen: function () {
|
2014-10-30 02:11:21 +03:00
|
|
|
return !!this.world.getItemCount();
|
2011-12-06 07:50:25 +04:00
|
|
|
},
|
2011-12-23 05:47:21 +04:00
|
|
|
|
2014-11-04 22:53:39 +03:00
|
|
|
// deprecated
|
2012-02-01 00:59:09 +04:00
|
|
|
openDzi: function ( dzi ) {
|
2014-10-30 03:06:14 +03:00
|
|
|
$.console.error( "[Viewer.openDzi] this function is deprecated; use Viewer.open() instead." );
|
2013-03-26 17:02:34 +04:00
|
|
|
return this.open( dzi );
|
|
|
|
},
|
|
|
|
|
2014-11-04 22:53:39 +03:00
|
|
|
// deprecated
|
2013-03-26 17:02:34 +04:00
|
|
|
openTileSource: function ( tileSource ) {
|
2014-10-30 03:06:14 +03:00
|
|
|
$.console.error( "[Viewer.openTileSource] this function is deprecated; use Viewer.open() instead." );
|
2013-03-26 17:02:34 +04:00
|
|
|
return this.open( tileSource );
|
2011-12-06 07:50:25 +04:00
|
|
|
},
|
2011-12-23 05:47:21 +04:00
|
|
|
|
2012-02-01 00:59:09 +04:00
|
|
|
/**
|
2014-10-30 03:23:54 +03:00
|
|
|
* Open tiled images into the viewer, closing any others.
|
2017-10-26 21:36:30 +03:00
|
|
|
* To get the TiledImage instance created by open, add an event listener for
|
|
|
|
* {@link OpenSeadragon.Viewer.html#.event:open}, which when fired can be used to get access
|
|
|
|
* to the instance, i.e., viewer.world.getItemAt(0).
|
2012-02-01 00:59:09 +04:00
|
|
|
* @function
|
2014-10-30 03:06:14 +03:00
|
|
|
* @param {Array|String|Object|Function} tileSources - This can be a TiledImage
|
|
|
|
* specifier, a TileSource specifier, or an array of either. A TiledImage specifier
|
2014-10-30 03:23:54 +03:00
|
|
|
* is the same as the options parameter for {@link OpenSeadragon.Viewer#addTiledImage},
|
|
|
|
* except for the index property; images are added in sequence.
|
2014-10-30 03:06:14 +03:00
|
|
|
* A TileSource specifier is anything you could pass as the tileSource property
|
2017-10-26 21:36:30 +03:00
|
|
|
* of the options parameter for {@link OpenSeadragon.Viewer#addTiledImage}.
|
2017-05-14 16:56:21 +03:00
|
|
|
* @param {Number} initialPage - If sequenceMode is true, display this page initially
|
2017-05-15 20:13:34 +03:00
|
|
|
* for the given tileSources. If specified, will overwrite the Viewer's existing initialPage property.
|
2012-02-18 22:13:05 +04:00
|
|
|
* @return {OpenSeadragon.Viewer} Chainable.
|
2013-11-22 00:19:07 +04:00
|
|
|
* @fires OpenSeadragon.Viewer.event:open
|
|
|
|
* @fires OpenSeadragon.Viewer.event:open-failed
|
2012-02-01 00:59:09 +04:00
|
|
|
*/
|
2017-05-14 16:56:21 +03:00
|
|
|
open: function (tileSources, initialPage) {
|
2013-12-09 18:26:36 +04:00
|
|
|
var _this = this;
|
2012-04-03 11:08:27 +04:00
|
|
|
|
2014-10-30 02:11:21 +03:00
|
|
|
this.close();
|
2013-06-28 22:32:57 +04:00
|
|
|
|
2014-10-30 02:11:21 +03:00
|
|
|
if (!tileSources) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-11-17 23:57:49 +03:00
|
|
|
if (this.sequenceMode && $.isArray(tileSources)) {
|
2014-11-18 01:03:14 +03:00
|
|
|
if (this.referenceStrip) {
|
|
|
|
this.referenceStrip.destroy();
|
|
|
|
this.referenceStrip = null;
|
|
|
|
}
|
|
|
|
|
2017-05-14 16:56:21 +03:00
|
|
|
if (typeof initialPage != 'undefined' && !isNaN(initialPage)) {
|
|
|
|
this.initialPage = initialPage;
|
|
|
|
}
|
|
|
|
|
2014-11-17 23:57:49 +03:00
|
|
|
this.tileSources = tileSources;
|
2014-11-18 01:03:14 +03:00
|
|
|
this._sequenceIndex = Math.max(0, Math.min(this.tileSources.length - 1, this.initialPage));
|
|
|
|
if (this.tileSources.length) {
|
|
|
|
this.open(this.tileSources[this._sequenceIndex]);
|
|
|
|
|
|
|
|
if ( this.showReferenceStrip ){
|
2017-06-24 18:58:19 +03:00
|
|
|
this.addReferenceStrip();
|
2014-11-18 01:03:14 +03:00
|
|
|
}
|
2014-11-17 23:57:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
this._updateSequenceButtons( this._sequenceIndex );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-10-30 02:11:21 +03:00
|
|
|
if (!$.isArray(tileSources)) {
|
|
|
|
tileSources = [tileSources];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!tileSources.length) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-02-10 22:30:36 +03:00
|
|
|
this._opening = true;
|
|
|
|
|
2014-10-30 02:11:21 +03:00
|
|
|
var expected = tileSources.length;
|
|
|
|
var successes = 0;
|
|
|
|
var failures = 0;
|
|
|
|
var failEvent;
|
|
|
|
|
|
|
|
var checkCompletion = function() {
|
|
|
|
if (successes + failures === expected) {
|
|
|
|
if (successes) {
|
2014-11-15 03:51:02 +03:00
|
|
|
if (_this._firstOpen || !_this.preserveViewport) {
|
2014-10-30 02:11:21 +03:00
|
|
|
_this.viewport.goHome( true );
|
2014-11-22 02:18:25 +03:00
|
|
|
_this.viewport.update();
|
2014-10-30 02:11:21 +03:00
|
|
|
}
|
|
|
|
|
2014-11-15 03:51:02 +03:00
|
|
|
_this._firstOpen = false;
|
|
|
|
|
2014-10-30 02:11:21 +03:00
|
|
|
var source = tileSources[0];
|
|
|
|
if (source.tileSource) {
|
|
|
|
source = source.tileSource;
|
|
|
|
}
|
|
|
|
|
2014-11-04 04:14:17 +03:00
|
|
|
// Global overlays
|
2015-01-13 01:10:49 +03:00
|
|
|
if( _this.overlays && !_this.preserveOverlays ){
|
|
|
|
for ( var i = 0; i < _this.overlays.length; i++ ) {
|
|
|
|
_this.currentOverlays[ i ] = getOverlayObject( _this, _this.overlays[ i ] );
|
|
|
|
}
|
2014-11-04 04:14:17 +03:00
|
|
|
}
|
|
|
|
|
2014-11-21 02:33:13 +03:00
|
|
|
_this._drawOverlays();
|
2015-02-10 22:30:36 +03:00
|
|
|
_this._opening = false;
|
2014-11-21 02:33:13 +03:00
|
|
|
|
2014-10-30 02:11:21 +03:00
|
|
|
/**
|
|
|
|
* Raised when the viewer has opened and loaded one or more TileSources.
|
|
|
|
*
|
|
|
|
* @event open
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
|
|
|
* @property {OpenSeadragon.TileSource} source - The tile source that was opened.
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
|
|
|
// TODO: what if there are multiple sources?
|
|
|
|
_this.raiseEvent( 'open', { source: source } );
|
|
|
|
} else {
|
2015-02-10 22:30:36 +03:00
|
|
|
_this._opening = false;
|
|
|
|
|
2014-10-30 02:11:21 +03:00
|
|
|
/**
|
|
|
|
* Raised when an error occurs loading a TileSource.
|
|
|
|
*
|
|
|
|
* @event open-failed
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
|
|
|
* @property {String} message - Information about what failed.
|
|
|
|
* @property {String} source - The tile source that failed.
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
|
|
|
_this.raiseEvent( 'open-failed', failEvent );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var doOne = function(options) {
|
|
|
|
if (!$.isPlainObject(options) || !options.tileSource) {
|
|
|
|
options = {
|
|
|
|
tileSource: options
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.index !== undefined) {
|
|
|
|
$.console.error('[Viewer.open] setting indexes here is not supported; use addTiledImage instead');
|
|
|
|
delete options.index;
|
|
|
|
}
|
|
|
|
|
2014-12-03 00:17:56 +03:00
|
|
|
if (options.collectionImmediately === undefined) {
|
|
|
|
options.collectionImmediately = true;
|
|
|
|
}
|
|
|
|
|
2014-10-30 02:11:21 +03:00
|
|
|
var originalSuccess = options.success;
|
|
|
|
options.success = function(event) {
|
|
|
|
successes++;
|
2015-10-27 23:00:45 +03:00
|
|
|
|
2015-10-17 10:48:09 +03:00
|
|
|
// TODO: now that options has other things besides tileSource, the overlays
|
|
|
|
// should probably be at the options level, not the tileSource level.
|
|
|
|
if (options.tileSource.overlays) {
|
|
|
|
for (var i = 0; i < options.tileSource.overlays.length; i++) {
|
|
|
|
_this.addOverlay(options.tileSource.overlays[i]);
|
|
|
|
}
|
|
|
|
}
|
2014-10-30 02:11:21 +03:00
|
|
|
|
|
|
|
if (originalSuccess) {
|
|
|
|
originalSuccess(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
checkCompletion();
|
|
|
|
};
|
|
|
|
|
|
|
|
var originalError = options.error;
|
|
|
|
options.error = function(event) {
|
|
|
|
failures++;
|
|
|
|
|
|
|
|
if (!failEvent) {
|
|
|
|
failEvent = event;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (originalError) {
|
|
|
|
originalError(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
checkCompletion();
|
|
|
|
};
|
|
|
|
|
|
|
|
_this.addTiledImage(options);
|
|
|
|
};
|
|
|
|
|
2014-11-04 04:14:17 +03:00
|
|
|
// TileSources
|
2014-10-30 02:11:21 +03:00
|
|
|
for (var i = 0; i < tileSources.length; i++) {
|
|
|
|
doOne(tileSources[i]);
|
|
|
|
}
|
2012-04-03 11:08:27 +04:00
|
|
|
|
2012-02-18 22:13:05 +04:00
|
|
|
return this;
|
2011-12-06 07:50:25 +04:00
|
|
|
},
|
2011-12-23 05:47:21 +04:00
|
|
|
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-02-01 00:59:09 +04:00
|
|
|
/**
|
|
|
|
* @function
|
2012-02-18 22:13:05 +04:00
|
|
|
* @return {OpenSeadragon.Viewer} Chainable.
|
2013-11-22 00:19:07 +04:00
|
|
|
* @fires OpenSeadragon.Viewer.event:close
|
2012-02-01 00:59:09 +04:00
|
|
|
*/
|
2012-04-03 11:08:27 +04:00
|
|
|
close: function ( ) {
|
2014-06-18 21:35:23 +04:00
|
|
|
if ( !THIS[ this.hash ] ) {
|
|
|
|
//this viewer has already been destroyed: returning immediately
|
|
|
|
return this;
|
|
|
|
}
|
2014-07-18 03:24:28 +04:00
|
|
|
|
2015-02-10 22:30:36 +03:00
|
|
|
this._opening = false;
|
|
|
|
|
2013-06-17 22:31:41 +04:00
|
|
|
if ( this.navigator ) {
|
|
|
|
this.navigator.close();
|
|
|
|
}
|
|
|
|
|
2017-01-08 17:52:57 +03:00
|
|
|
if (!this.preserveOverlays) {
|
2015-01-09 05:21:16 +03:00
|
|
|
this.clearOverlays();
|
|
|
|
this.overlaysContainer.innerHTML = "";
|
|
|
|
}
|
2013-02-13 07:40:08 +04:00
|
|
|
|
2014-10-30 02:11:21 +03:00
|
|
|
THIS[ this.hash ].animating = false;
|
2014-09-25 00:58:09 +04:00
|
|
|
this.world.removeAll();
|
2015-02-20 23:12:34 +03:00
|
|
|
this.imageLoader.clear();
|
2015-03-03 11:29:44 +03:00
|
|
|
|
2013-11-16 10:19:53 +04:00
|
|
|
/**
|
2013-11-22 00:19:07 +04:00
|
|
|
* Raised when the viewer is closed (see {@link OpenSeadragon.Viewer#close}).
|
|
|
|
*
|
2013-11-16 10:19:53 +04:00
|
|
|
* @event close
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
2013-11-16 10:19:53 +04:00
|
|
|
*/
|
2013-10-15 22:11:08 +04:00
|
|
|
this.raiseEvent( 'close' );
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-02-18 22:13:05 +04:00
|
|
|
return this;
|
2011-12-06 07:50:25 +04:00
|
|
|
},
|
2012-01-24 17:03:50 +04:00
|
|
|
|
2013-09-12 17:41:51 +04:00
|
|
|
|
2013-08-07 04:54:20 +04:00
|
|
|
/**
|
2014-06-18 23:56:36 +04:00
|
|
|
* Function to destroy the viewer and clean up everything created by OpenSeadragon.
|
2014-07-18 03:24:28 +04:00
|
|
|
*
|
2014-06-18 23:56:36 +04:00
|
|
|
* Example:
|
|
|
|
* var viewer = OpenSeadragon({
|
|
|
|
* [...]
|
|
|
|
* });
|
|
|
|
*
|
|
|
|
* //when you are done with the viewer:
|
|
|
|
* viewer.destroy();
|
|
|
|
* viewer = null; //important
|
|
|
|
*
|
2013-08-07 04:54:20 +04:00
|
|
|
* @function
|
|
|
|
*/
|
|
|
|
destroy: function( ) {
|
2014-10-30 02:39:43 +03:00
|
|
|
if ( !THIS[ this.hash ] ) {
|
|
|
|
//this viewer has already been destroyed: returning immediately
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-08-07 04:54:20 +04:00
|
|
|
this.close();
|
|
|
|
|
2015-02-14 00:26:44 +03:00
|
|
|
this.clearOverlays();
|
|
|
|
this.overlaysContainer.innerHTML = "";
|
|
|
|
|
2014-06-18 21:35:23 +04:00
|
|
|
//TODO: implement this...
|
|
|
|
//this.unbindSequenceControls()
|
2014-07-18 03:24:28 +04:00
|
|
|
//this.unbindStandardControls()
|
|
|
|
|
2014-11-18 01:03:14 +03:00
|
|
|
if (this.referenceStrip) {
|
|
|
|
this.referenceStrip.destroy();
|
|
|
|
this.referenceStrip = null;
|
|
|
|
}
|
|
|
|
|
2014-10-30 02:11:21 +03:00
|
|
|
if ( this._updateRequestId !== null ) {
|
|
|
|
$.cancelAnimationFrame( this._updateRequestId );
|
|
|
|
this._updateRequestId = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( this.drawer ) {
|
|
|
|
this.drawer.destroy();
|
|
|
|
}
|
|
|
|
|
2013-08-08 11:49:24 +04:00
|
|
|
this.removeAllHandlers();
|
2013-08-07 04:54:20 +04:00
|
|
|
|
|
|
|
// Go through top element (passed to us) and remove all children
|
|
|
|
// Use removeChild to make sure it handles SVG or any non-html
|
|
|
|
// also it performs better - http://jsperf.com/innerhtml-vs-removechild/15
|
2013-08-08 11:49:24 +04:00
|
|
|
if (this.element){
|
|
|
|
while (this.element.firstChild) {
|
|
|
|
this.element.removeChild(this.element.firstChild);
|
|
|
|
}
|
2013-08-07 04:54:20 +04:00
|
|
|
}
|
|
|
|
|
2013-08-08 11:49:24 +04:00
|
|
|
// destroy the mouse trackers
|
|
|
|
if (this.innerTracker){
|
|
|
|
this.innerTracker.destroy();
|
|
|
|
}
|
|
|
|
if (this.outerTracker){
|
|
|
|
this.outerTracker.destroy();
|
|
|
|
}
|
2014-06-18 21:35:23 +04:00
|
|
|
|
|
|
|
THIS[ this.hash ] = null;
|
|
|
|
delete THIS[ this.hash ];
|
|
|
|
|
2013-08-07 04:54:20 +04:00
|
|
|
// clear all our references to dom objects
|
|
|
|
this.canvas = null;
|
|
|
|
this.container = null;
|
|
|
|
|
|
|
|
// clear our reference to the main element - they will need to pass it in again, creating a new viewer
|
|
|
|
this.element = null;
|
|
|
|
},
|
|
|
|
|
2012-02-01 00:59:09 +04:00
|
|
|
/**
|
|
|
|
* @function
|
2012-03-09 20:04:28 +04:00
|
|
|
* @return {Boolean}
|
2012-02-01 00:59:09 +04:00
|
|
|
*/
|
2012-03-09 20:04:28 +04:00
|
|
|
isMouseNavEnabled: function () {
|
|
|
|
return this.innerTracker.isTracking();
|
2011-12-06 07:50:25 +04:00
|
|
|
},
|
2012-01-24 17:03:50 +04:00
|
|
|
|
2012-02-01 00:59:09 +04:00
|
|
|
/**
|
|
|
|
* @function
|
2013-11-16 10:19:53 +04:00
|
|
|
* @param {Boolean} enabled - true to enable, false to disable
|
2012-02-18 22:13:05 +04:00
|
|
|
* @return {OpenSeadragon.Viewer} Chainable.
|
2013-11-22 00:19:07 +04:00
|
|
|
* @fires OpenSeadragon.Viewer.event:mouse-enabled
|
2012-02-01 00:59:09 +04:00
|
|
|
*/
|
2012-03-09 20:04:28 +04:00
|
|
|
setMouseNavEnabled: function( enabled ){
|
|
|
|
this.innerTracker.setTracking( enabled );
|
2016-02-11 23:54:31 +03:00
|
|
|
this.outerTracker.setTracking( enabled );
|
2013-11-16 10:19:53 +04:00
|
|
|
/**
|
2013-11-22 00:19:07 +04:00
|
|
|
* Raised when mouse/touch navigation is enabled or disabled (see {@link OpenSeadragon.Viewer#setMouseNavEnabled}).
|
|
|
|
*
|
2013-11-16 10:19:53 +04:00
|
|
|
* @event mouse-enabled
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
|
|
|
* @property {Boolean} enabled
|
2013-11-18 18:56:32 +04:00
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
2013-11-16 10:19:53 +04:00
|
|
|
*/
|
2013-10-11 04:00:15 +04:00
|
|
|
this.raiseEvent( 'mouse-enabled', { enabled: enabled } );
|
2012-02-18 22:13:05 +04:00
|
|
|
return this;
|
2011-12-06 07:50:25 +04:00
|
|
|
},
|
2012-01-24 17:03:50 +04:00
|
|
|
|
2012-03-09 20:04:28 +04:00
|
|
|
|
2012-02-01 00:59:09 +04:00
|
|
|
/**
|
|
|
|
* @function
|
2012-02-18 22:13:05 +04:00
|
|
|
* @return {Boolean}
|
2012-02-01 00:59:09 +04:00
|
|
|
*/
|
2012-03-20 03:03:58 +04:00
|
|
|
areControlsEnabled: function () {
|
2012-08-29 22:46:34 +04:00
|
|
|
var enabled = this.controls.length,
|
|
|
|
i;
|
|
|
|
for( i = 0; i < this.controls.length; i++ ){
|
|
|
|
enabled = enabled && this.controls[ i ].isVisibile();
|
|
|
|
}
|
|
|
|
return enabled;
|
2011-12-06 07:50:25 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
|
2012-02-01 00:59:09 +04:00
|
|
|
/**
|
2013-05-29 00:54:13 +04:00
|
|
|
* Shows or hides the controls (e.g. the default navigation buttons).
|
2013-06-19 21:33:25 +04:00
|
|
|
*
|
2012-02-01 00:59:09 +04:00
|
|
|
* @function
|
2013-05-29 00:54:13 +04:00
|
|
|
* @param {Boolean} true to show, false to hide.
|
2012-03-09 20:04:28 +04:00
|
|
|
* @return {OpenSeadragon.Viewer} Chainable.
|
2013-11-22 00:19:07 +04:00
|
|
|
* @fires OpenSeadragon.Viewer.event:controls-enabled
|
2012-02-01 00:59:09 +04:00
|
|
|
*/
|
2012-03-20 03:03:58 +04:00
|
|
|
setControlsEnabled: function( enabled ) {
|
|
|
|
if( enabled ){
|
|
|
|
abortControlsAutoHide( this );
|
|
|
|
} else {
|
|
|
|
beginControlsAutoHide( this );
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2013-11-16 10:19:53 +04:00
|
|
|
/**
|
2013-11-22 00:19:07 +04:00
|
|
|
* Raised when the navigation controls are shown or hidden (see {@link OpenSeadragon.Viewer#setControlsEnabled}).
|
|
|
|
*
|
2013-11-16 10:19:53 +04:00
|
|
|
* @event controls-enabled
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
|
|
|
* @property {Boolean} enabled
|
2013-11-18 18:56:32 +04:00
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
2013-11-16 10:19:53 +04:00
|
|
|
*/
|
2013-10-11 04:00:15 +04:00
|
|
|
this.raiseEvent( 'controls-enabled', { enabled: enabled } );
|
2013-02-14 04:44:23 +04:00
|
|
|
return this;
|
2011-12-06 07:50:25 +04:00
|
|
|
},
|
|
|
|
|
2017-06-19 23:29:41 +03:00
|
|
|
/**
|
|
|
|
* Turns debugging mode on or off for this viewer.
|
|
|
|
*
|
|
|
|
* @function
|
|
|
|
* @param {Boolean} true to turn debug on, false to turn debug off.
|
|
|
|
*/
|
|
|
|
setDebugMode: function(debugMode){
|
|
|
|
|
|
|
|
for (var i = 0; i < this.world.getItemCount(); i++) {
|
|
|
|
this.world.getItemAt(i).debugMode = debugMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.debugMode = debugMode;
|
|
|
|
this.forceRedraw();
|
|
|
|
},
|
|
|
|
|
2012-02-01 00:59:09 +04:00
|
|
|
/**
|
|
|
|
* @function
|
2012-02-18 22:13:05 +04:00
|
|
|
* @return {Boolean}
|
2012-02-01 00:59:09 +04:00
|
|
|
*/
|
2012-03-09 20:04:28 +04:00
|
|
|
isFullPage: function () {
|
2013-03-26 17:02:34 +04:00
|
|
|
return THIS[ this.hash ].fullPage;
|
2011-12-06 07:50:25 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
|
2012-02-01 00:59:09 +04:00
|
|
|
/**
|
2012-02-10 07:16:09 +04:00
|
|
|
* Toggle full page mode.
|
2012-02-01 00:59:09 +04:00
|
|
|
* @function
|
2012-02-10 07:16:09 +04:00
|
|
|
* @param {Boolean} fullPage
|
|
|
|
* If true, enter full page mode. If false, exit full page mode.
|
2012-02-18 22:13:05 +04:00
|
|
|
* @return {OpenSeadragon.Viewer} Chainable.
|
2013-11-22 00:19:07 +04:00
|
|
|
* @fires OpenSeadragon.Viewer.event:pre-full-page
|
|
|
|
* @fires OpenSeadragon.Viewer.event:full-page
|
2012-02-01 00:59:09 +04:00
|
|
|
*/
|
2011-12-08 06:10:13 +04:00
|
|
|
setFullPage: function( fullPage ) {
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2013-11-03 05:01:04 +04:00
|
|
|
var body = document.body,
|
|
|
|
bodyStyle = body.style,
|
|
|
|
docStyle = document.documentElement.style,
|
|
|
|
_this = this,
|
2012-02-10 07:16:09 +04:00
|
|
|
nodes,
|
|
|
|
i;
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-02-10 07:16:09 +04:00
|
|
|
//dont bother modifying the DOM if we are already in full page mode.
|
2012-01-24 17:03:50 +04:00
|
|
|
if ( fullPage == this.isFullPage() ) {
|
2013-11-03 05:01:04 +04:00
|
|
|
return this;
|
2012-01-24 17:03:50 +04:00
|
|
|
}
|
2013-11-01 06:19:22 +04:00
|
|
|
|
2013-11-09 00:03:54 +04:00
|
|
|
var fullPageEventArgs = {
|
|
|
|
fullPage: fullPage,
|
|
|
|
preventDefaultAction: false
|
|
|
|
};
|
2013-11-16 10:19:53 +04:00
|
|
|
/**
|
2013-11-22 00:19:07 +04:00
|
|
|
* Raised when the viewer is about to change to/from full-page mode (see {@link OpenSeadragon.Viewer#setFullPage}).
|
|
|
|
*
|
2013-11-16 10:19:53 +04:00
|
|
|
* @event pre-full-page
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
|
|
|
* @property {Boolean} fullPage - True if entering full-page mode, false if exiting full-page mode.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @property {Boolean} preventDefaultAction - Set to true to prevent full-page mode change. Default: false.
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
2013-11-16 10:19:53 +04:00
|
|
|
*/
|
2013-11-09 00:03:54 +04:00
|
|
|
this.raiseEvent( 'pre-full-page', fullPageEventArgs );
|
|
|
|
if ( fullPageEventArgs.preventDefaultAction ) {
|
|
|
|
return this;
|
|
|
|
}
|
2013-02-27 07:34:44 +04:00
|
|
|
|
2011-12-08 06:10:13 +04:00
|
|
|
if ( fullPage ) {
|
2013-11-01 06:19:22 +04:00
|
|
|
|
2013-11-03 05:01:04 +04:00
|
|
|
this.elementSize = $.getElementSize( this.element );
|
|
|
|
this.pageScroll = $.getPageScroll();
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2013-11-09 00:03:54 +04:00
|
|
|
this.elementMargin = this.element.style.margin;
|
|
|
|
this.element.style.margin = "0";
|
|
|
|
this.elementPadding = this.element.style.padding;
|
|
|
|
this.element.style.padding = "0";
|
|
|
|
|
2013-11-03 05:01:04 +04:00
|
|
|
this.bodyMargin = bodyStyle.margin;
|
|
|
|
this.docMargin = docStyle.margin;
|
|
|
|
bodyStyle.margin = "0";
|
|
|
|
docStyle.margin = "0";
|
2013-10-23 18:00:08 +04:00
|
|
|
|
2013-11-03 05:01:04 +04:00
|
|
|
this.bodyPadding = bodyStyle.padding;
|
|
|
|
this.docPadding = docStyle.padding;
|
|
|
|
bodyStyle.padding = "0";
|
|
|
|
docStyle.padding = "0";
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2013-11-03 05:01:04 +04:00
|
|
|
this.bodyWidth = bodyStyle.width;
|
2016-05-13 23:38:56 +03:00
|
|
|
this.docWidth = docStyle.width;
|
2013-11-03 05:01:04 +04:00
|
|
|
bodyStyle.width = "100%";
|
2016-05-13 23:38:56 +03:00
|
|
|
docStyle.width = "100%";
|
|
|
|
|
|
|
|
this.bodyHeight = bodyStyle.height;
|
|
|
|
this.docHeight = docStyle.height;
|
2013-11-03 05:01:04 +04:00
|
|
|
bodyStyle.height = "100%";
|
2016-05-13 23:38:56 +03:00
|
|
|
docStyle.height = "100%";
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2012-02-10 07:16:09 +04:00
|
|
|
//when entering full screen on the ipad it wasnt sufficient to leave
|
2013-06-19 21:33:25 +04:00
|
|
|
//the body intact as only only the top half of the screen would
|
2012-02-10 07:16:09 +04:00
|
|
|
//respond to touch events on the canvas, while the bottom half treated
|
|
|
|
//them as touch events on the document body. Thus we remove and store
|
|
|
|
//the bodies elements and replace them when we leave full screen.
|
|
|
|
this.previousBody = [];
|
2012-10-13 07:40:59 +04:00
|
|
|
THIS[ this.hash ].prevElementParent = this.element.parentNode;
|
2013-03-26 17:02:34 +04:00
|
|
|
THIS[ this.hash ].prevNextSibling = this.element.nextSibling;
|
2013-09-12 17:41:51 +04:00
|
|
|
THIS[ this.hash ].prevElementWidth = this.element.style.width;
|
|
|
|
THIS[ this.hash ].prevElementHeight = this.element.style.height;
|
2012-03-09 20:04:28 +04:00
|
|
|
nodes = body.childNodes.length;
|
2013-11-03 05:01:04 +04:00
|
|
|
for ( i = 0; i < nodes; i++ ) {
|
2012-03-09 20:04:28 +04:00
|
|
|
this.previousBody.push( body.childNodes[ 0 ] );
|
|
|
|
body.removeChild( body.childNodes[ 0 ] );
|
|
|
|
}
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-03-09 20:04:28 +04:00
|
|
|
//If we've got a toolbar, we need to enable the user to use css to
|
|
|
|
//preserve it in fullpage mode
|
2013-11-03 05:01:04 +04:00
|
|
|
if ( this.toolbar && this.toolbar.element ) {
|
2012-03-09 20:04:28 +04:00
|
|
|
//save a reference to the parent so we can put it back
|
|
|
|
//in the long run we need a better strategy
|
|
|
|
this.toolbar.parentNode = this.toolbar.element.parentNode;
|
2012-03-16 19:36:28 +04:00
|
|
|
this.toolbar.nextSibling = this.toolbar.element.nextSibling;
|
2012-03-09 20:04:28 +04:00
|
|
|
body.appendChild( this.toolbar.element );
|
|
|
|
|
|
|
|
//Make sure the user has some ability to style the toolbar based
|
|
|
|
//on the mode
|
2013-05-13 06:53:41 +04:00
|
|
|
$.addClass( this.toolbar.element, 'fullpage' );
|
2012-03-16 19:36:28 +04:00
|
|
|
}
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2013-05-13 07:02:18 +04:00
|
|
|
$.addClass( this.element, 'fullpage' );
|
2012-10-13 07:40:59 +04:00
|
|
|
body.appendChild( this.element );
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2013-11-03 05:01:04 +04:00
|
|
|
this.element.style.height = $.getWindowSize().y + 'px';
|
|
|
|
this.element.style.width = $.getWindowSize().x + 'px';
|
2013-02-28 23:28:05 +04:00
|
|
|
|
2013-11-03 05:01:04 +04:00
|
|
|
if ( this.toolbar && this.toolbar.element ) {
|
2012-10-13 07:40:59 +04:00
|
|
|
this.element.style.height = (
|
2013-02-28 23:28:05 +04:00
|
|
|
$.getElementSize( this.element ).y - $.getElementSize( this.toolbar.element ).y
|
2012-10-13 07:40:59 +04:00
|
|
|
) + 'px';
|
|
|
|
}
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2013-03-26 17:02:34 +04:00
|
|
|
THIS[ this.hash ].fullPage = true;
|
|
|
|
|
2011-12-08 06:10:13 +04:00
|
|
|
// mouse will be inside container now
|
2013-10-11 04:00:15 +04:00
|
|
|
$.delegate( this, onContainerEnter )( {} );
|
2011-12-08 06:10:13 +04:00
|
|
|
|
2011-12-06 07:50:25 +04:00
|
|
|
} else {
|
2013-02-27 02:31:47 +04:00
|
|
|
|
2013-11-09 00:03:54 +04:00
|
|
|
this.element.style.margin = this.elementMargin;
|
|
|
|
this.element.style.padding = this.elementPadding;
|
|
|
|
|
2013-11-03 05:01:04 +04:00
|
|
|
bodyStyle.margin = this.bodyMargin;
|
|
|
|
docStyle.margin = this.docMargin;
|
|
|
|
|
|
|
|
bodyStyle.padding = this.bodyPadding;
|
|
|
|
docStyle.padding = this.docPadding;
|
|
|
|
|
|
|
|
bodyStyle.width = this.bodyWidth;
|
2016-05-13 23:38:56 +03:00
|
|
|
docStyle.width = this.docWidth;
|
|
|
|
|
2013-11-03 05:01:04 +04:00
|
|
|
bodyStyle.height = this.bodyHeight;
|
2016-05-13 23:38:56 +03:00
|
|
|
docStyle.height = this.docHeight;
|
2013-11-03 05:01:04 +04:00
|
|
|
|
|
|
|
body.removeChild( this.element );
|
|
|
|
nodes = this.previousBody.length;
|
|
|
|
for ( i = 0; i < nodes; i++ ) {
|
|
|
|
body.appendChild( this.previousBody.shift() );
|
2012-03-09 20:04:28 +04:00
|
|
|
}
|
|
|
|
|
2013-11-03 05:01:04 +04:00
|
|
|
$.removeClass( this.element, 'fullpage' );
|
|
|
|
THIS[ this.hash ].prevElementParent.insertBefore(
|
|
|
|
this.element,
|
|
|
|
THIS[ this.hash ].prevNextSibling
|
2013-11-08 22:56:13 +04:00
|
|
|
);
|
2013-11-03 05:01:04 +04:00
|
|
|
|
|
|
|
//If we've got a toolbar, we need to enable the user to use css to
|
|
|
|
//reset it to its original state
|
|
|
|
if ( this.toolbar && this.toolbar.element ) {
|
|
|
|
body.removeChild( this.toolbar.element );
|
|
|
|
|
|
|
|
//Make sure the user has some ability to style the toolbar based
|
|
|
|
//on the mode
|
|
|
|
$.removeClass( this.toolbar.element, 'fullpage' );
|
|
|
|
|
|
|
|
this.toolbar.parentNode.insertBefore(
|
|
|
|
this.toolbar.element,
|
|
|
|
this.toolbar.nextSibling
|
2013-11-08 22:56:13 +04:00
|
|
|
);
|
2013-11-03 05:01:04 +04:00
|
|
|
delete this.toolbar.parentNode;
|
|
|
|
delete this.toolbar.nextSibling;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.element.style.width = THIS[ this.hash ].prevElementWidth;
|
|
|
|
this.element.style.height = THIS[ this.hash ].prevElementHeight;
|
|
|
|
|
|
|
|
// After exiting fullPage or fullScreen, it can take some time
|
|
|
|
// before the browser can actually set the scroll.
|
2013-11-08 22:56:13 +04:00
|
|
|
var restoreScrollCounter = 0;
|
2013-11-03 05:01:04 +04:00
|
|
|
var restoreScroll = function() {
|
|
|
|
$.setPageScroll( _this.pageScroll );
|
|
|
|
var pageScroll = $.getPageScroll();
|
2013-11-08 22:56:13 +04:00
|
|
|
restoreScrollCounter++;
|
2017-01-08 17:52:57 +03:00
|
|
|
if (restoreScrollCounter < 10 &&
|
|
|
|
(pageScroll.x !== _this.pageScroll.x ||
|
|
|
|
pageScroll.y !== _this.pageScroll.y)) {
|
2013-11-03 05:01:04 +04:00
|
|
|
$.requestAnimationFrame( restoreScroll );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
$.requestAnimationFrame( restoreScroll );
|
|
|
|
|
|
|
|
THIS[ this.hash ].fullPage = false;
|
|
|
|
|
|
|
|
// mouse will likely be outside now
|
|
|
|
$.delegate( this, onContainerExit )( { } );
|
|
|
|
|
2011-12-06 07:50:25 +04:00
|
|
|
}
|
2011-12-08 06:10:13 +04:00
|
|
|
|
2013-12-14 21:11:14 +04:00
|
|
|
if ( this.navigator && this.viewport ) {
|
|
|
|
this.navigator.update( this.viewport );
|
|
|
|
}
|
|
|
|
|
2013-11-16 10:19:53 +04:00
|
|
|
/**
|
2013-11-22 00:19:07 +04:00
|
|
|
* Raised when the viewer has changed to/from full-page mode (see {@link OpenSeadragon.Viewer#setFullPage}).
|
|
|
|
*
|
2013-11-16 10:19:53 +04:00
|
|
|
* @event full-page
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
|
|
|
* @property {Boolean} fullPage - True if changed to full-page mode, false if exited full-page mode.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
2013-11-16 10:19:53 +04:00
|
|
|
*/
|
2013-11-03 05:01:04 +04:00
|
|
|
this.raiseEvent( 'full-page', { fullPage: fullPage } );
|
|
|
|
|
2012-02-18 22:13:05 +04:00
|
|
|
return this;
|
2011-12-06 07:50:25 +04:00
|
|
|
},
|
|
|
|
|
2013-11-03 05:01:04 +04:00
|
|
|
/**
|
|
|
|
* Toggle full screen mode if supported. Toggle full page mode otherwise.
|
|
|
|
* @function
|
|
|
|
* @param {Boolean} fullScreen
|
|
|
|
* If true, enter full screen mode. If false, exit full screen mode.
|
|
|
|
* @return {OpenSeadragon.Viewer} Chainable.
|
2013-11-22 00:19:07 +04:00
|
|
|
* @fires OpenSeadragon.Viewer.event:pre-full-screen
|
|
|
|
* @fires OpenSeadragon.Viewer.event:full-screen
|
2013-11-03 05:01:04 +04:00
|
|
|
*/
|
|
|
|
setFullScreen: function( fullScreen ) {
|
|
|
|
var _this = this;
|
|
|
|
|
|
|
|
if ( !$.supportsFullScreen ) {
|
|
|
|
return this.setFullPage( fullScreen );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $.isFullScreen() === fullScreen ) {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2013-11-09 00:03:54 +04:00
|
|
|
var fullScreeEventArgs = {
|
|
|
|
fullScreen: fullScreen,
|
|
|
|
preventDefaultAction: false
|
|
|
|
};
|
2013-11-16 10:19:53 +04:00
|
|
|
/**
|
2013-11-22 00:19:07 +04:00
|
|
|
* Raised when the viewer is about to change to/from full-screen mode (see {@link OpenSeadragon.Viewer#setFullScreen}).
|
2015-05-16 17:36:00 +03:00
|
|
|
* Note: the pre-full-screen event is not raised when the user is exiting
|
|
|
|
* full-screen mode by pressing the Esc key. In that case, consider using
|
|
|
|
* the full-screen, pre-full-page or full-page events.
|
2013-11-22 00:19:07 +04:00
|
|
|
*
|
2013-11-16 10:19:53 +04:00
|
|
|
* @event pre-full-screen
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
|
|
|
* @property {Boolean} fullScreen - True if entering full-screen mode, false if exiting full-screen mode.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @property {Boolean} preventDefaultAction - Set to true to prevent full-screen mode change. Default: false.
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
2013-11-16 10:19:53 +04:00
|
|
|
*/
|
2013-11-09 00:03:54 +04:00
|
|
|
this.raiseEvent( 'pre-full-screen', fullScreeEventArgs );
|
|
|
|
if ( fullScreeEventArgs.preventDefaultAction ) {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2013-11-03 05:01:04 +04:00
|
|
|
if ( fullScreen ) {
|
|
|
|
|
|
|
|
this.setFullPage( true );
|
2013-11-09 00:03:54 +04:00
|
|
|
// If the full page mode is not actually entered, we need to prevent
|
|
|
|
// the full screen mode.
|
|
|
|
if ( !this.isFullPage() ) {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.fullPageStyleWidth = this.element.style.width;
|
|
|
|
this.fullPageStyleHeight = this.element.style.height;
|
|
|
|
this.element.style.width = '100%';
|
|
|
|
this.element.style.height = '100%';
|
2013-11-03 05:01:04 +04:00
|
|
|
|
|
|
|
var onFullScreenChange = function() {
|
|
|
|
var isFullScreen = $.isFullScreen();
|
|
|
|
if ( !isFullScreen ) {
|
|
|
|
$.removeEvent( document, $.fullScreenEventName, onFullScreenChange );
|
|
|
|
$.removeEvent( document, $.fullScreenErrorEventName, onFullScreenChange );
|
|
|
|
|
|
|
|
_this.setFullPage( false );
|
2013-11-09 00:03:54 +04:00
|
|
|
if ( _this.isFullPage() ) {
|
|
|
|
_this.element.style.width = _this.fullPageStyleWidth;
|
|
|
|
_this.element.style.height = _this.fullPageStyleHeight;
|
|
|
|
}
|
2013-11-03 05:01:04 +04:00
|
|
|
}
|
2013-12-14 21:11:14 +04:00
|
|
|
if ( _this.navigator && _this.viewport ) {
|
2018-08-10 11:23:33 +03:00
|
|
|
//09/08/2018 - Fabroh : Fix issue #1504 : Ensure to get the navigator updated on fullscreen out with custom location with a timeout
|
|
|
|
setTimeout(function(){
|
|
|
|
_this.navigator.update( _this.viewport );
|
|
|
|
});
|
2013-12-14 21:11:14 +04:00
|
|
|
}
|
2013-11-16 10:19:53 +04:00
|
|
|
/**
|
2013-11-22 00:19:07 +04:00
|
|
|
* Raised when the viewer has changed to/from full-screen mode (see {@link OpenSeadragon.Viewer#setFullScreen}).
|
|
|
|
*
|
2013-11-16 10:19:53 +04:00
|
|
|
* @event full-screen
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
|
|
|
* @property {Boolean} fullScreen - True if changed to full-screen mode, false if exited full-screen mode.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
2013-11-16 10:19:53 +04:00
|
|
|
*/
|
2013-11-03 05:01:04 +04:00
|
|
|
_this.raiseEvent( 'full-screen', { fullScreen: isFullScreen } );
|
|
|
|
};
|
|
|
|
$.addEvent( document, $.fullScreenEventName, onFullScreenChange );
|
|
|
|
$.addEvent( document, $.fullScreenErrorEventName, onFullScreenChange );
|
|
|
|
|
|
|
|
$.requestFullScreen( document.body );
|
|
|
|
|
|
|
|
} else {
|
2014-03-18 01:01:36 +04:00
|
|
|
$.exitFullScreen();
|
2013-11-03 05:01:04 +04:00
|
|
|
}
|
|
|
|
return this;
|
|
|
|
},
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-02-01 00:59:09 +04:00
|
|
|
/**
|
|
|
|
* @function
|
2012-03-09 20:04:28 +04:00
|
|
|
* @return {Boolean}
|
2012-02-01 00:59:09 +04:00
|
|
|
*/
|
2012-03-09 20:04:28 +04:00
|
|
|
isVisible: function () {
|
|
|
|
return this.container.style.visibility != "hidden";
|
2011-12-06 07:50:25 +04:00
|
|
|
},
|
|
|
|
|
2012-03-09 20:04:28 +04:00
|
|
|
|
2012-02-01 00:59:09 +04:00
|
|
|
/**
|
|
|
|
* @function
|
2013-11-16 10:19:53 +04:00
|
|
|
* @param {Boolean} visible
|
2012-02-18 22:13:05 +04:00
|
|
|
* @return {OpenSeadragon.Viewer} Chainable.
|
2013-11-22 00:19:07 +04:00
|
|
|
* @fires OpenSeadragon.Viewer.event:visible
|
2012-02-01 00:59:09 +04:00
|
|
|
*/
|
2011-12-08 06:10:13 +04:00
|
|
|
setVisible: function( visible ){
|
|
|
|
this.container.style.visibility = visible ? "" : "hidden";
|
2013-11-16 10:19:53 +04:00
|
|
|
/**
|
2013-11-22 00:19:07 +04:00
|
|
|
* Raised when the viewer is shown or hidden (see {@link OpenSeadragon.Viewer#setVisible}).
|
|
|
|
*
|
2013-11-16 10:19:53 +04:00
|
|
|
* @event visible
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
|
|
|
* @property {Boolean} visible
|
2013-11-18 18:56:32 +04:00
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
2013-11-16 10:19:53 +04:00
|
|
|
*/
|
2013-10-11 04:00:15 +04:00
|
|
|
this.raiseEvent( 'visible', { visible: visible } );
|
2012-02-18 22:13:05 +04:00
|
|
|
return this;
|
2012-04-11 01:02:24 +04:00
|
|
|
},
|
|
|
|
|
2013-12-01 02:28:17 +04:00
|
|
|
/**
|
2014-08-20 02:02:04 +04:00
|
|
|
* Add a tiled image to the viewer.
|
2013-12-09 18:26:36 +04:00
|
|
|
* options.tileSource can be anything that {@link OpenSeadragon.Viewer#open}
|
2014-08-20 02:02:04 +04:00
|
|
|
* supports except arrays of images.
|
2014-08-01 03:17:46 +04:00
|
|
|
* Note that you can specify options.width or options.height, but not both.
|
2014-08-20 02:02:04 +04:00
|
|
|
* The other dimension will be calculated according to the item's aspect ratio.
|
2014-12-03 00:17:56 +03:00
|
|
|
* If collectionMode is on (see {@link OpenSeadragon.Options}), the new image is
|
|
|
|
* automatically arranged with the others.
|
2013-12-01 02:28:17 +04:00
|
|
|
* @function
|
2013-12-09 18:26:36 +04:00
|
|
|
* @param {Object} options
|
2014-10-30 03:06:14 +03:00
|
|
|
* @param {String|Object|Function} options.tileSource - The TileSource specifier.
|
|
|
|
* A String implies a url used to determine the tileSource implementation
|
|
|
|
* based on the file extension of url. JSONP is implied by *.js,
|
|
|
|
* otherwise the url is retrieved as text and the resulting text is
|
|
|
|
* introspected to determine if its json, xml, or text and parsed.
|
|
|
|
* An Object implies an inline configuration which has a single
|
|
|
|
* property sufficient for being able to determine tileSource
|
|
|
|
* implementation. If the object has a property which is a function
|
|
|
|
* named 'getTileUrl', it is treated as a custom TileSource.
|
2014-08-20 02:02:04 +04:00
|
|
|
* @param {Number} [options.index] The index of the item. Added on top of
|
|
|
|
* all other items if not specified.
|
2015-08-19 22:29:55 +03:00
|
|
|
* @param {Boolean} [options.replace=false] If true, the item at options.index will be
|
|
|
|
* removed and the new item is added in its place. options.tileSource will be
|
|
|
|
* interpreted and fetched if necessary before the old item is removed to avoid leaving
|
|
|
|
* a gap in the world.
|
2014-11-24 22:59:06 +03:00
|
|
|
* @param {Number} [options.x=0] The X position for the image in viewport coordinates.
|
|
|
|
* @param {Number} [options.y=0] The Y position for the image in viewport coordinates.
|
|
|
|
* @param {Number} [options.width=1] The width for the image in viewport coordinates.
|
|
|
|
* @param {Number} [options.height] The height for the image in viewport coordinates.
|
2016-03-22 23:41:28 +03:00
|
|
|
* @param {OpenSeadragon.Rect} [options.fitBounds] The bounds in viewport coordinates
|
|
|
|
* to fit the image into. If specified, x, y, width and height get ignored.
|
|
|
|
* @param {OpenSeadragon.Placement} [options.fitBoundsPlacement=OpenSeadragon.Placement.CENTER]
|
|
|
|
* How to anchor the image in the bounds if options.fitBounds is set.
|
2015-03-20 02:38:52 +03:00
|
|
|
* @param {OpenSeadragon.Rect} [options.clip] - An area, in image pixels, to clip to
|
|
|
|
* (portions of the image outside of this area will not be visible). Only works on
|
|
|
|
* browsers that support the HTML5 canvas.
|
2017-05-30 20:00:43 +03:00
|
|
|
* @param {Number} [options.opacity=1] Proportional opacity of the tiled images (1=opaque, 0=hidden)
|
2016-11-04 05:39:00 +03:00
|
|
|
* @param {Boolean} [options.preload=false] Default switch for loading hidden images (true loads, false blocks)
|
2016-08-21 13:54:33 +03:00
|
|
|
* @param {Number} [options.degrees=0] Initial rotation of the tiled image around
|
2016-08-28 14:39:26 +03:00
|
|
|
* its top left corner in degrees.
|
2016-01-07 23:47:17 +03:00
|
|
|
* @param {String} [options.compositeOperation] How the image is composited onto other images.
|
2016-07-21 01:43:53 +03:00
|
|
|
* @param {String} [options.crossOriginPolicy] The crossOriginPolicy for this specific image,
|
|
|
|
* overriding viewer.crossOriginPolicy.
|
2016-10-22 00:28:12 +03:00
|
|
|
* @param {Boolean} [options.ajaxWithCredentials] Whether to set withCredentials on tile AJAX
|
|
|
|
* @param {Boolean} [options.loadTilesWithAjax]
|
|
|
|
* Whether to load tile data using AJAX requests.
|
|
|
|
* Defaults to the setting in {@link OpenSeadragon.Options}.
|
2016-11-08 20:27:30 +03:00
|
|
|
* @param {Object} [options.ajaxHeaders]
|
2016-10-22 00:28:12 +03:00
|
|
|
* A set of headers to include when making tile AJAX requests.
|
|
|
|
* Note that these headers will be merged over any headers specified in {@link OpenSeadragon.Options}.
|
2016-12-19 08:39:32 +03:00
|
|
|
* Specifying a falsy value for a header will clear its existing value set at the Viewer level (if any).
|
2016-10-22 00:28:12 +03:00
|
|
|
* requests.
|
2014-10-25 02:18:32 +04:00
|
|
|
* @param {Function} [options.success] A function that gets called when the image is
|
2014-10-30 02:11:21 +03:00
|
|
|
* successfully added. It's passed the event object which contains a single property:
|
2017-10-25 23:51:17 +03:00
|
|
|
* "item", which is the resulting instance of TiledImage.
|
2014-10-30 02:11:21 +03:00
|
|
|
* @param {Function} [options.error] A function that gets called if the image is
|
|
|
|
* unable to be added. It's passed the error event object, which contains "message"
|
|
|
|
* and "source" properties.
|
2014-12-03 00:17:56 +03:00
|
|
|
* @param {Boolean} [options.collectionImmediately=false] If collectionMode is on,
|
|
|
|
* specifies whether to snap to the new arrangement immediately or to animate to it.
|
2015-04-10 15:31:08 +03:00
|
|
|
* @param {String|CanvasGradient|CanvasPattern|Function} [options.placeholderFillStyle] - See {@link OpenSeadragon.Options}.
|
2014-08-20 02:02:04 +04:00
|
|
|
* @fires OpenSeadragon.World.event:add-item
|
|
|
|
* @fires OpenSeadragon.Viewer.event:add-item-failed
|
2013-12-01 02:28:17 +04:00
|
|
|
*/
|
2014-08-20 02:02:04 +04:00
|
|
|
addTiledImage: function( options ) {
|
|
|
|
$.console.assert(options, "[Viewer.addTiledImage] options is required");
|
|
|
|
$.console.assert(options.tileSource, "[Viewer.addTiledImage] options.tileSource is required");
|
2015-08-19 22:29:55 +03:00
|
|
|
$.console.assert(!options.replace || (options.index > -1 && options.index < this.world.getItemCount()),
|
|
|
|
"[Viewer.addTiledImage] if options.replace is used, options.index must be a valid index in Viewer.world");
|
2014-08-20 02:02:04 +04:00
|
|
|
|
2014-11-19 02:45:03 +03:00
|
|
|
var _this = this;
|
2013-12-09 18:26:36 +04:00
|
|
|
|
2015-08-21 20:01:32 +03:00
|
|
|
if (options.replace) {
|
|
|
|
options.replaceItem = _this.world.getItemAt(options.index);
|
|
|
|
}
|
|
|
|
|
2014-10-30 02:11:21 +03:00
|
|
|
this._hideMessage();
|
2013-12-09 18:26:36 +04:00
|
|
|
|
2015-04-13 19:59:13 +03:00
|
|
|
if (options.placeholderFillStyle === undefined) {
|
|
|
|
options.placeholderFillStyle = this.placeholderFillStyle;
|
|
|
|
}
|
2015-04-21 02:25:36 +03:00
|
|
|
if (options.opacity === undefined) {
|
|
|
|
options.opacity = this.opacity;
|
|
|
|
}
|
2016-11-03 03:45:33 +03:00
|
|
|
if (options.preload === undefined) {
|
|
|
|
options.preload = this.preload;
|
|
|
|
}
|
Update to allow setting of globalCompositeOperation when
html <canvas> is used to process multiple tiledImages to blend
is a specific way.
(special handling,
when compositeOperation is 'source-over' and opacity is 1,
useSketch is false, otherwise useSketch is true
)
Valid values are 'source-atop', 'source-in', 'source-out',
'destination-over', 'destination-atop', 'destination-in',
'destination-out', 'lighter', 'copy' or 'xor'
http://www.w3schools.com/tags/canvas_globalcompositeoperation.asp
2016-01-06 18:58:36 +03:00
|
|
|
if (options.compositeOperation === undefined) {
|
|
|
|
options.compositeOperation = this.compositeOperation;
|
|
|
|
}
|
2016-07-21 01:43:53 +03:00
|
|
|
if (options.crossOriginPolicy === undefined) {
|
2016-07-28 18:35:43 +03:00
|
|
|
options.crossOriginPolicy = options.tileSource.crossOriginPolicy !== undefined ? options.tileSource.crossOriginPolicy : this.crossOriginPolicy;
|
2016-07-21 01:43:53 +03:00
|
|
|
}
|
2016-10-22 00:28:12 +03:00
|
|
|
if (options.ajaxWithCredentials === undefined) {
|
|
|
|
options.ajaxWithCredentials = this.ajaxWithCredentials;
|
|
|
|
}
|
|
|
|
if (options.loadTilesWithAjax === undefined) {
|
|
|
|
options.loadTilesWithAjax = this.loadTilesWithAjax;
|
|
|
|
}
|
2016-11-08 20:27:30 +03:00
|
|
|
if (options.ajaxHeaders === undefined || options.ajaxHeaders === null) {
|
|
|
|
options.ajaxHeaders = this.ajaxHeaders;
|
|
|
|
} else if ($.isPlainObject(options.ajaxHeaders) && $.isPlainObject(this.ajaxHeaders)) {
|
|
|
|
options.ajaxHeaders = $.extend({}, this.ajaxHeaders, options.ajaxHeaders);
|
2016-10-22 00:28:12 +03:00
|
|
|
}
|
2015-04-10 15:31:08 +03:00
|
|
|
|
2014-11-19 02:45:03 +03:00
|
|
|
var myQueueItem = {
|
|
|
|
options: options
|
|
|
|
};
|
|
|
|
|
2014-08-20 02:02:04 +04:00
|
|
|
function raiseAddItemFailed( event ) {
|
2015-09-24 00:19:02 +03:00
|
|
|
for (var i = 0; i < _this._loadQueue.length; i++) {
|
2014-11-19 02:45:03 +03:00
|
|
|
if (_this._loadQueue[i] === myQueueItem) {
|
|
|
|
_this._loadQueue.splice(i, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-25 18:57:35 +03:00
|
|
|
if (_this._loadQueue.length === 0) {
|
|
|
|
refreshWorld(myQueueItem);
|
|
|
|
}
|
|
|
|
|
2014-01-12 04:15:28 +04:00
|
|
|
/**
|
2014-08-20 02:02:04 +04:00
|
|
|
* Raised when an error occurs while adding a item.
|
|
|
|
* @event add-item-failed
|
2014-01-12 04:15:28 +04:00
|
|
|
* @memberOf OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
|
|
|
* @property {String} message
|
|
|
|
* @property {String} source
|
2014-08-20 02:02:04 +04:00
|
|
|
* @property {Object} options The options passed to the addTiledImage method.
|
2014-01-12 04:15:28 +04:00
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
2014-08-20 02:02:04 +04:00
|
|
|
_this.raiseEvent( 'add-item-failed', event );
|
2014-10-30 02:11:21 +03:00
|
|
|
|
|
|
|
if (options.error) {
|
|
|
|
options.error(event);
|
|
|
|
}
|
2014-01-12 04:15:28 +04:00
|
|
|
}
|
|
|
|
|
2015-09-25 18:57:35 +03:00
|
|
|
function refreshWorld(theItem) {
|
|
|
|
if (_this.collectionMode) {
|
|
|
|
_this.world.arrange({
|
|
|
|
immediately: theItem.options.collectionImmediately,
|
|
|
|
rows: _this.collectionRows,
|
|
|
|
columns: _this.collectionColumns,
|
|
|
|
layout: _this.collectionLayout,
|
|
|
|
tileSize: _this.collectionTileSize,
|
|
|
|
tileMargin: _this.collectionTileMargin
|
|
|
|
});
|
2015-10-08 01:09:17 +03:00
|
|
|
_this.world.setAutoRefigureSizes(true);
|
2015-09-25 18:57:35 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-10 02:19:17 +03:00
|
|
|
if ($.isArray(options.tileSource)) {
|
|
|
|
setTimeout(function() {
|
2014-08-20 02:02:04 +04:00
|
|
|
raiseAddItemFailed({
|
2014-10-30 02:11:21 +03:00
|
|
|
message: "[Viewer.addTiledImage] Sequences can not be added; add them one at a time instead.",
|
2015-11-10 02:19:17 +03:00
|
|
|
source: options.tileSource,
|
2014-01-12 04:15:28 +04:00
|
|
|
options: options
|
|
|
|
});
|
2015-11-10 02:19:17 +03:00
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._loadQueue.push(myQueueItem);
|
|
|
|
|
2017-06-22 08:43:34 +03:00
|
|
|
function processReadyItems() {
|
2014-11-19 02:45:03 +03:00
|
|
|
var queueItem, tiledImage, optionsClone;
|
|
|
|
while (_this._loadQueue.length) {
|
|
|
|
queueItem = _this._loadQueue[0];
|
|
|
|
if (!queueItem.tileSource) {
|
|
|
|
break;
|
|
|
|
}
|
2014-10-30 02:11:21 +03:00
|
|
|
|
2014-11-19 02:45:03 +03:00
|
|
|
_this._loadQueue.splice(0, 1);
|
|
|
|
|
2015-08-19 22:29:55 +03:00
|
|
|
if (queueItem.options.replace) {
|
2015-10-09 01:29:01 +03:00
|
|
|
var newIndex = _this.world.getIndexOfItem(queueItem.options.replaceItem);
|
2015-08-21 20:01:32 +03:00
|
|
|
if (newIndex != -1) {
|
2015-10-09 01:29:01 +03:00
|
|
|
queueItem.options.index = newIndex;
|
2015-08-21 20:01:32 +03:00
|
|
|
}
|
2015-10-09 01:29:01 +03:00
|
|
|
_this.world.removeItem(queueItem.options.replaceItem);
|
2015-08-19 22:29:55 +03:00
|
|
|
}
|
|
|
|
|
2014-11-19 02:45:03 +03:00
|
|
|
tiledImage = new $.TiledImage({
|
|
|
|
viewer: _this,
|
|
|
|
source: queueItem.tileSource,
|
|
|
|
viewport: _this.viewport,
|
|
|
|
drawer: _this.drawer,
|
|
|
|
tileCache: _this.tileCache,
|
|
|
|
imageLoader: _this.imageLoader,
|
|
|
|
x: queueItem.options.x,
|
|
|
|
y: queueItem.options.y,
|
|
|
|
width: queueItem.options.width,
|
|
|
|
height: queueItem.options.height,
|
2016-03-22 23:41:28 +03:00
|
|
|
fitBounds: queueItem.options.fitBounds,
|
|
|
|
fitBoundsPlacement: queueItem.options.fitBoundsPlacement,
|
2015-03-18 20:03:44 +03:00
|
|
|
clip: queueItem.options.clip,
|
2015-04-10 15:31:08 +03:00
|
|
|
placeholderFillStyle: queueItem.options.placeholderFillStyle,
|
2015-04-19 23:10:37 +03:00
|
|
|
opacity: queueItem.options.opacity,
|
2016-11-03 03:45:33 +03:00
|
|
|
preload: queueItem.options.preload,
|
2016-08-17 16:43:08 +03:00
|
|
|
degrees: queueItem.options.degrees,
|
Update to allow setting of globalCompositeOperation when
html <canvas> is used to process multiple tiledImages to blend
is a specific way.
(special handling,
when compositeOperation is 'source-over' and opacity is 1,
useSketch is false, otherwise useSketch is true
)
Valid values are 'source-atop', 'source-in', 'source-out',
'destination-over', 'destination-atop', 'destination-in',
'destination-out', 'lighter', 'copy' or 'xor'
http://www.w3schools.com/tags/canvas_globalcompositeoperation.asp
2016-01-06 18:58:36 +03:00
|
|
|
compositeOperation: queueItem.options.compositeOperation,
|
2014-12-02 22:44:02 +03:00
|
|
|
springStiffness: _this.springStiffness,
|
|
|
|
animationTime: _this.animationTime,
|
2014-11-19 02:45:03 +03:00
|
|
|
minZoomImageRatio: _this.minZoomImageRatio,
|
|
|
|
wrapHorizontal: _this.wrapHorizontal,
|
|
|
|
wrapVertical: _this.wrapVertical,
|
|
|
|
immediateRender: _this.immediateRender,
|
|
|
|
blendTime: _this.blendTime,
|
|
|
|
alwaysBlend: _this.alwaysBlend,
|
|
|
|
minPixelRatio: _this.minPixelRatio,
|
2015-11-04 18:04:50 +03:00
|
|
|
smoothTileEdgesMinZoom: _this.smoothTileEdgesMinZoom,
|
2016-06-17 09:32:50 +03:00
|
|
|
iOSDevice: _this.iOSDevice,
|
2016-07-21 01:43:53 +03:00
|
|
|
crossOriginPolicy: queueItem.options.crossOriginPolicy,
|
2016-10-22 00:28:12 +03:00
|
|
|
ajaxWithCredentials: queueItem.options.ajaxWithCredentials,
|
|
|
|
loadTilesWithAjax: queueItem.options.loadTilesWithAjax,
|
2016-11-08 20:27:30 +03:00
|
|
|
ajaxHeaders: queueItem.options.ajaxHeaders,
|
2015-04-10 15:31:08 +03:00
|
|
|
debugMode: _this.debugMode
|
2014-09-24 03:15:03 +04:00
|
|
|
});
|
|
|
|
|
2015-09-25 18:57:35 +03:00
|
|
|
if (_this.collectionMode) {
|
|
|
|
_this.world.setAutoRefigureSizes(false);
|
|
|
|
}
|
2014-11-19 02:45:03 +03:00
|
|
|
_this.world.addItem( tiledImage, {
|
|
|
|
index: queueItem.options.index
|
2014-10-30 02:11:21 +03:00
|
|
|
});
|
2014-11-19 02:45:03 +03:00
|
|
|
|
2015-09-25 18:57:35 +03:00
|
|
|
if (_this._loadQueue.length === 0) {
|
|
|
|
//this restores the autoRefigureSizes flag to true.
|
|
|
|
refreshWorld(queueItem);
|
2014-11-19 02:45:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_this.world.getItemCount() === 1 && !_this.preserveViewport) {
|
|
|
|
_this.viewport.goHome(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_this.navigator) {
|
|
|
|
optionsClone = $.extend({}, queueItem.options, {
|
2016-05-26 20:24:03 +03:00
|
|
|
replace: false, // navigator already removed the layer, nothing to replace
|
2014-11-19 02:45:03 +03:00
|
|
|
originalTiledImage: tiledImage,
|
|
|
|
tileSource: queueItem.tileSource
|
|
|
|
});
|
|
|
|
|
|
|
|
_this.navigator.addTiledImage(optionsClone);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (queueItem.options.success) {
|
|
|
|
queueItem.options.success({
|
|
|
|
item: tiledImage
|
|
|
|
});
|
|
|
|
}
|
2014-10-25 02:18:32 +04:00
|
|
|
}
|
2017-06-22 08:43:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
getTileSourceImplementation( this, options.tileSource, options, function( tileSource ) {
|
|
|
|
|
|
|
|
myQueueItem.tileSource = tileSource;
|
|
|
|
|
|
|
|
// add everybody at the front of the queue that's ready to go
|
|
|
|
processReadyItems();
|
2013-12-09 18:26:36 +04:00
|
|
|
}, function( event ) {
|
2014-01-06 04:20:45 +04:00
|
|
|
event.options = options;
|
2014-08-20 02:02:04 +04:00
|
|
|
raiseAddItemFailed(event);
|
2017-06-22 08:43:34 +03:00
|
|
|
|
|
|
|
// add everybody at the front of the queue that's ready to go
|
|
|
|
processReadyItems();
|
2013-12-09 18:26:36 +04:00
|
|
|
} );
|
2014-08-20 02:02:04 +04:00
|
|
|
},
|
2013-12-09 18:26:36 +04:00
|
|
|
|
2016-01-27 02:02:11 +03:00
|
|
|
/**
|
|
|
|
* Add a simple image to the viewer.
|
2016-01-28 05:49:05 +03:00
|
|
|
* The options are the same as the ones in {@link OpenSeadragon.Viewer#addTiledImage}
|
2016-01-27 02:02:11 +03:00
|
|
|
* except for options.tileSource which is replaced by options.url.
|
|
|
|
* @function
|
|
|
|
* @param {Object} options - See {@link OpenSeadragon.Viewer#addTiledImage}
|
|
|
|
* for all the options
|
|
|
|
* @param {String} options.url - The URL of the image to add.
|
|
|
|
* @fires OpenSeadragon.World.event:add-item
|
|
|
|
* @fires OpenSeadragon.Viewer.event:add-item-failed
|
|
|
|
*/
|
|
|
|
addSimpleImage: function(options) {
|
|
|
|
$.console.assert(options, "[Viewer.addSimpleImage] options is required");
|
|
|
|
$.console.assert(options.url, "[Viewer.addSimpleImage] options.url is required");
|
|
|
|
|
|
|
|
var opts = $.extend({}, options, {
|
|
|
|
tileSource: {
|
|
|
|
type: 'image',
|
|
|
|
url: options.url
|
|
|
|
}
|
|
|
|
});
|
|
|
|
delete opts.url;
|
|
|
|
this.addTiledImage(opts);
|
|
|
|
},
|
|
|
|
|
2014-11-04 22:53:39 +03:00
|
|
|
// deprecated
|
2014-08-20 02:02:04 +04:00
|
|
|
addLayer: function( options ) {
|
2014-11-04 22:53:39 +03:00
|
|
|
var _this = this;
|
2014-08-20 02:02:04 +04:00
|
|
|
|
|
|
|
$.console.error( "[Viewer.addLayer] this function is deprecated; use Viewer.addTiledImage() instead." );
|
|
|
|
|
2014-10-30 02:11:21 +03:00
|
|
|
var optionsClone = $.extend({}, options, {
|
|
|
|
success: function(event) {
|
2014-11-04 22:53:39 +03:00
|
|
|
_this.raiseEvent("add-layer", {
|
2014-10-30 02:11:21 +03:00
|
|
|
options: options,
|
|
|
|
drawer: event.item
|
|
|
|
});
|
|
|
|
},
|
|
|
|
error: function(event) {
|
2014-11-04 22:53:39 +03:00
|
|
|
_this.raiseEvent("add-layer-failed", event);
|
2014-10-30 02:11:21 +03:00
|
|
|
}
|
|
|
|
});
|
2014-08-20 02:02:04 +04:00
|
|
|
|
2014-10-30 02:11:21 +03:00
|
|
|
this.addTiledImage(optionsClone);
|
2013-12-09 18:26:36 +04:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2014-11-04 22:53:39 +03:00
|
|
|
// deprecated
|
2014-01-12 03:08:04 +04:00
|
|
|
getLayerAtLevel: function( level ) {
|
2014-08-20 02:02:04 +04:00
|
|
|
$.console.error( "[Viewer.getLayerAtLevel] this function is deprecated; use World.getItemAt() instead." );
|
|
|
|
return this.world.getItemAt(level);
|
2014-01-12 03:08:04 +04:00
|
|
|
},
|
|
|
|
|
2014-11-04 22:53:39 +03:00
|
|
|
// deprecated
|
2014-01-12 03:08:04 +04:00
|
|
|
getLevelOfLayer: function( drawer ) {
|
2014-08-20 02:02:04 +04:00
|
|
|
$.console.error( "[Viewer.getLevelOfLayer] this function is deprecated; use World.getIndexOfItem() instead." );
|
|
|
|
return this.world.getIndexOfItem(drawer);
|
2013-12-09 18:26:36 +04:00
|
|
|
},
|
|
|
|
|
2014-11-04 22:53:39 +03:00
|
|
|
// deprecated
|
2014-01-22 04:24:47 +04:00
|
|
|
getLayersCount: function() {
|
2014-08-20 02:02:04 +04:00
|
|
|
$.console.error( "[Viewer.getLayersCount] this function is deprecated; use World.getItemCount() instead." );
|
|
|
|
return this.world.getItemCount();
|
2014-01-11 21:52:44 +04:00
|
|
|
},
|
|
|
|
|
2014-11-04 22:53:39 +03:00
|
|
|
// deprecated
|
2013-12-09 18:26:36 +04:00
|
|
|
setLayerLevel: function( drawer, level ) {
|
2014-08-20 02:02:04 +04:00
|
|
|
$.console.error( "[Viewer.setLayerLevel] this function is deprecated; use World.setItemIndex() instead." );
|
|
|
|
return this.world.setItemIndex(drawer, level);
|
2013-12-09 18:26:36 +04:00
|
|
|
},
|
|
|
|
|
2014-11-04 22:53:39 +03:00
|
|
|
// deprecated
|
2013-12-09 18:26:36 +04:00
|
|
|
removeLayer: function( drawer ) {
|
2014-08-20 02:02:04 +04:00
|
|
|
$.console.error( "[Viewer.removeLayer] this function is deprecated; use World.removeItem() instead." );
|
|
|
|
return this.world.removeItem(drawer);
|
2013-12-09 18:26:36 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2014-08-09 03:15:23 +04:00
|
|
|
* Force the viewer to redraw its contents.
|
2013-12-09 18:26:36 +04:00
|
|
|
* @returns {OpenSeadragon.Viewer} Chainable.
|
|
|
|
*/
|
|
|
|
forceRedraw: function() {
|
|
|
|
THIS[ this.hash ].forceRedraw = true;
|
|
|
|
return this;
|
2013-12-01 02:28:17 +04:00
|
|
|
},
|
2013-02-14 04:44:23 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @function
|
|
|
|
* @return {OpenSeadragon.Viewer} Chainable.
|
|
|
|
*/
|
2012-04-11 01:02:24 +04:00
|
|
|
bindSequenceControls: function(){
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-04-11 01:02:24 +04:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Image Sequence Controls
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
var onFocusHandler = $.delegate( this, onFocus ),
|
|
|
|
onBlurHandler = $.delegate( this, onBlur ),
|
|
|
|
onNextHandler = $.delegate( this, onNext ),
|
|
|
|
onPreviousHandler = $.delegate( this, onPrevious ),
|
|
|
|
navImages = this.navImages,
|
2017-01-08 17:52:57 +03:00
|
|
|
useGroup = true;
|
2012-04-11 01:02:24 +04:00
|
|
|
|
2014-11-15 04:19:04 +03:00
|
|
|
if( this.showSequenceControl ){
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-04-11 01:02:24 +04:00
|
|
|
if( this.previousButton || this.nextButton ){
|
2013-06-19 21:33:25 +04:00
|
|
|
//if we are binding to custom buttons then layout and
|
2012-04-11 01:02:24 +04:00
|
|
|
//grouping is the responsibility of the page author
|
|
|
|
useGroup = false;
|
|
|
|
}
|
|
|
|
|
2013-06-19 21:33:25 +04:00
|
|
|
this.previousButton = new $.Button({
|
2012-04-11 01:02:24 +04:00
|
|
|
element: this.previousButton ? $.getElement( this.previousButton ) : null,
|
|
|
|
clickTimeThreshold: this.clickTimeThreshold,
|
|
|
|
clickDistThreshold: this.clickDistThreshold,
|
|
|
|
tooltip: $.getString( "Tooltips.PreviousPage" ),
|
|
|
|
srcRest: resolveUrl( this.prefixUrl, navImages.previous.REST ),
|
|
|
|
srcGroup: resolveUrl( this.prefixUrl, navImages.previous.GROUP ),
|
|
|
|
srcHover: resolveUrl( this.prefixUrl, navImages.previous.HOVER ),
|
|
|
|
srcDown: resolveUrl( this.prefixUrl, navImages.previous.DOWN ),
|
|
|
|
onRelease: onPreviousHandler,
|
|
|
|
onFocus: onFocusHandler,
|
|
|
|
onBlur: onBlurHandler
|
|
|
|
});
|
|
|
|
|
2013-06-19 21:33:25 +04:00
|
|
|
this.nextButton = new $.Button({
|
2012-04-11 01:02:24 +04:00
|
|
|
element: this.nextButton ? $.getElement( this.nextButton ) : null,
|
|
|
|
clickTimeThreshold: this.clickTimeThreshold,
|
|
|
|
clickDistThreshold: this.clickDistThreshold,
|
|
|
|
tooltip: $.getString( "Tooltips.NextPage" ),
|
|
|
|
srcRest: resolveUrl( this.prefixUrl, navImages.next.REST ),
|
|
|
|
srcGroup: resolveUrl( this.prefixUrl, navImages.next.GROUP ),
|
|
|
|
srcHover: resolveUrl( this.prefixUrl, navImages.next.HOVER ),
|
|
|
|
srcDown: resolveUrl( this.prefixUrl, navImages.next.DOWN ),
|
|
|
|
onRelease: onNextHandler,
|
|
|
|
onFocus: onFocusHandler,
|
|
|
|
onBlur: onBlurHandler
|
|
|
|
});
|
|
|
|
|
2013-06-19 01:19:09 +04:00
|
|
|
if( !this.navPrevNextWrap ){
|
|
|
|
this.previousButton.disable();
|
|
|
|
}
|
2012-04-11 01:02:24 +04:00
|
|
|
|
2014-11-15 04:19:04 +03:00
|
|
|
if (!this.tileSources || !this.tileSources.length) {
|
|
|
|
this.nextButton.disable();
|
|
|
|
}
|
|
|
|
|
2012-04-11 01:02:24 +04:00
|
|
|
if( useGroup ){
|
|
|
|
this.paging = new $.ButtonGroup({
|
2013-06-19 21:33:25 +04:00
|
|
|
buttons: [
|
|
|
|
this.previousButton,
|
|
|
|
this.nextButton
|
2012-04-11 01:02:24 +04:00
|
|
|
],
|
|
|
|
clickTimeThreshold: this.clickTimeThreshold,
|
|
|
|
clickDistThreshold: this.clickDistThreshold
|
|
|
|
});
|
|
|
|
|
|
|
|
this.pagingControl = this.paging.element;
|
|
|
|
|
|
|
|
if( this.toolbar ){
|
2013-06-19 21:33:25 +04:00
|
|
|
this.toolbar.addControl(
|
|
|
|
this.pagingControl,
|
2013-03-15 18:59:47 +04:00
|
|
|
{anchor: $.ControlAnchor.BOTTOM_RIGHT}
|
2012-04-11 01:02:24 +04:00
|
|
|
);
|
|
|
|
}else{
|
2013-06-19 21:33:25 +04:00
|
|
|
this.addControl(
|
|
|
|
this.pagingControl,
|
2013-12-09 22:04:39 +04:00
|
|
|
{anchor: this.sequenceControlAnchor || $.ControlAnchor.TOP_LEFT}
|
2012-04-11 01:02:24 +04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-02-14 04:44:23 +04:00
|
|
|
return this;
|
2012-04-11 01:02:24 +04:00
|
|
|
},
|
|
|
|
|
2013-02-14 04:44:23 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @function
|
|
|
|
* @return {OpenSeadragon.Viewer} Chainable.
|
|
|
|
*/
|
2012-04-11 01:02:24 +04:00
|
|
|
bindStandardControls: function(){
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Navigation Controls
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
var beginZoomingInHandler = $.delegate( this, beginZoomingIn ),
|
|
|
|
endZoomingHandler = $.delegate( this, endZooming ),
|
|
|
|
doSingleZoomInHandler = $.delegate( this, doSingleZoomIn ),
|
|
|
|
beginZoomingOutHandler = $.delegate( this, beginZoomingOut ),
|
|
|
|
doSingleZoomOutHandler = $.delegate( this, doSingleZoomOut ),
|
|
|
|
onHomeHandler = $.delegate( this, onHome ),
|
2013-11-08 22:56:13 +04:00
|
|
|
onFullScreenHandler = $.delegate( this, onFullScreen ),
|
2014-02-21 00:57:39 +04:00
|
|
|
onRotateLeftHandler = $.delegate( this, onRotateLeft ),
|
|
|
|
onRotateRightHandler = $.delegate( this, onRotateRight ),
|
2018-04-11 13:25:46 +03:00
|
|
|
onFlipHandler = $.delegate( this, onFlip),
|
2012-04-11 01:02:24 +04:00
|
|
|
onFocusHandler = $.delegate( this, onFocus ),
|
|
|
|
onBlurHandler = $.delegate( this, onBlur ),
|
|
|
|
navImages = this.navImages,
|
|
|
|
buttons = [],
|
2017-01-08 17:52:57 +03:00
|
|
|
useGroup = true;
|
2012-04-11 01:02:24 +04:00
|
|
|
|
|
|
|
|
2014-04-07 22:11:33 +04:00
|
|
|
if ( this.showNavigationControl ) {
|
2012-04-11 01:02:24 +04:00
|
|
|
|
2014-04-07 22:11:33 +04:00
|
|
|
if( this.zoomInButton || this.zoomOutButton ||
|
|
|
|
this.homeButton || this.fullPageButton ||
|
2018-04-04 13:31:18 +03:00
|
|
|
this.rotateLeftButton || this.rotateRightButton ||
|
|
|
|
this.flipButton ) {
|
2013-06-19 21:33:25 +04:00
|
|
|
//if we are binding to custom buttons then layout and
|
2012-04-11 01:02:24 +04:00
|
|
|
//grouping is the responsibility of the page author
|
|
|
|
useGroup = false;
|
|
|
|
}
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2014-04-07 22:11:33 +04:00
|
|
|
if ( this.showZoomControl ) {
|
|
|
|
buttons.push( this.zoomInButton = new $.Button({
|
|
|
|
element: this.zoomInButton ? $.getElement( this.zoomInButton ) : null,
|
|
|
|
clickTimeThreshold: this.clickTimeThreshold,
|
|
|
|
clickDistThreshold: this.clickDistThreshold,
|
|
|
|
tooltip: $.getString( "Tooltips.ZoomIn" ),
|
|
|
|
srcRest: resolveUrl( this.prefixUrl, navImages.zoomIn.REST ),
|
|
|
|
srcGroup: resolveUrl( this.prefixUrl, navImages.zoomIn.GROUP ),
|
|
|
|
srcHover: resolveUrl( this.prefixUrl, navImages.zoomIn.HOVER ),
|
|
|
|
srcDown: resolveUrl( this.prefixUrl, navImages.zoomIn.DOWN ),
|
|
|
|
onPress: beginZoomingInHandler,
|
|
|
|
onRelease: endZoomingHandler,
|
|
|
|
onClick: doSingleZoomInHandler,
|
|
|
|
onEnter: beginZoomingInHandler,
|
|
|
|
onExit: endZoomingHandler,
|
|
|
|
onFocus: onFocusHandler,
|
|
|
|
onBlur: onBlurHandler
|
|
|
|
}));
|
2012-04-11 01:02:24 +04:00
|
|
|
|
2014-04-07 22:11:33 +04:00
|
|
|
buttons.push( this.zoomOutButton = new $.Button({
|
|
|
|
element: this.zoomOutButton ? $.getElement( this.zoomOutButton ) : null,
|
|
|
|
clickTimeThreshold: this.clickTimeThreshold,
|
|
|
|
clickDistThreshold: this.clickDistThreshold,
|
|
|
|
tooltip: $.getString( "Tooltips.ZoomOut" ),
|
|
|
|
srcRest: resolveUrl( this.prefixUrl, navImages.zoomOut.REST ),
|
|
|
|
srcGroup: resolveUrl( this.prefixUrl, navImages.zoomOut.GROUP ),
|
|
|
|
srcHover: resolveUrl( this.prefixUrl, navImages.zoomOut.HOVER ),
|
|
|
|
srcDown: resolveUrl( this.prefixUrl, navImages.zoomOut.DOWN ),
|
|
|
|
onPress: beginZoomingOutHandler,
|
|
|
|
onRelease: endZoomingHandler,
|
|
|
|
onClick: doSingleZoomOutHandler,
|
|
|
|
onEnter: beginZoomingOutHandler,
|
|
|
|
onExit: endZoomingHandler,
|
|
|
|
onFocus: onFocusHandler,
|
|
|
|
onBlur: onBlurHandler
|
|
|
|
}));
|
|
|
|
}
|
2012-04-11 01:02:24 +04:00
|
|
|
|
2014-04-07 22:11:33 +04:00
|
|
|
if ( this.showHomeControl ) {
|
|
|
|
buttons.push( this.homeButton = new $.Button({
|
|
|
|
element: this.homeButton ? $.getElement( this.homeButton ) : null,
|
|
|
|
clickTimeThreshold: this.clickTimeThreshold,
|
|
|
|
clickDistThreshold: this.clickDistThreshold,
|
|
|
|
tooltip: $.getString( "Tooltips.Home" ),
|
|
|
|
srcRest: resolveUrl( this.prefixUrl, navImages.home.REST ),
|
|
|
|
srcGroup: resolveUrl( this.prefixUrl, navImages.home.GROUP ),
|
|
|
|
srcHover: resolveUrl( this.prefixUrl, navImages.home.HOVER ),
|
|
|
|
srcDown: resolveUrl( this.prefixUrl, navImages.home.DOWN ),
|
|
|
|
onRelease: onHomeHandler,
|
|
|
|
onFocus: onFocusHandler,
|
|
|
|
onBlur: onBlurHandler
|
|
|
|
}));
|
|
|
|
}
|
2012-04-11 01:02:24 +04:00
|
|
|
|
2014-04-07 22:11:33 +04:00
|
|
|
if ( this.showFullPageControl ) {
|
|
|
|
buttons.push( this.fullPageButton = new $.Button({
|
|
|
|
element: this.fullPageButton ? $.getElement( this.fullPageButton ) : null,
|
|
|
|
clickTimeThreshold: this.clickTimeThreshold,
|
|
|
|
clickDistThreshold: this.clickDistThreshold,
|
|
|
|
tooltip: $.getString( "Tooltips.FullPage" ),
|
|
|
|
srcRest: resolveUrl( this.prefixUrl, navImages.fullpage.REST ),
|
|
|
|
srcGroup: resolveUrl( this.prefixUrl, navImages.fullpage.GROUP ),
|
|
|
|
srcHover: resolveUrl( this.prefixUrl, navImages.fullpage.HOVER ),
|
|
|
|
srcDown: resolveUrl( this.prefixUrl, navImages.fullpage.DOWN ),
|
|
|
|
onRelease: onFullScreenHandler,
|
|
|
|
onFocus: onFocusHandler,
|
|
|
|
onBlur: onBlurHandler
|
|
|
|
}));
|
|
|
|
}
|
2012-04-11 01:02:24 +04:00
|
|
|
|
2014-04-07 22:11:33 +04:00
|
|
|
if ( this.showRotationControl ) {
|
|
|
|
buttons.push( this.rotateLeftButton = new $.Button({
|
2014-03-03 20:28:28 +04:00
|
|
|
element: this.rotateLeftButton ? $.getElement( this.rotateLeftButton ) : null,
|
|
|
|
clickTimeThreshold: this.clickTimeThreshold,
|
|
|
|
clickDistThreshold: this.clickDistThreshold,
|
|
|
|
tooltip: $.getString( "Tooltips.RotateLeft" ),
|
|
|
|
srcRest: resolveUrl( this.prefixUrl, navImages.rotateleft.REST ),
|
|
|
|
srcGroup: resolveUrl( this.prefixUrl, navImages.rotateleft.GROUP ),
|
|
|
|
srcHover: resolveUrl( this.prefixUrl, navImages.rotateleft.HOVER ),
|
|
|
|
srcDown: resolveUrl( this.prefixUrl, navImages.rotateleft.DOWN ),
|
|
|
|
onRelease: onRotateLeftHandler,
|
|
|
|
onFocus: onFocusHandler,
|
|
|
|
onBlur: onBlurHandler
|
|
|
|
}));
|
|
|
|
|
2014-04-07 22:11:33 +04:00
|
|
|
buttons.push( this.rotateRightButton = new $.Button({
|
2014-03-03 20:28:28 +04:00
|
|
|
element: this.rotateRightButton ? $.getElement( this.rotateRightButton ) : null,
|
|
|
|
clickTimeThreshold: this.clickTimeThreshold,
|
|
|
|
clickDistThreshold: this.clickDistThreshold,
|
|
|
|
tooltip: $.getString( "Tooltips.RotateRight" ),
|
|
|
|
srcRest: resolveUrl( this.prefixUrl, navImages.rotateright.REST ),
|
|
|
|
srcGroup: resolveUrl( this.prefixUrl, navImages.rotateright.GROUP ),
|
|
|
|
srcHover: resolveUrl( this.prefixUrl, navImages.rotateright.HOVER ),
|
|
|
|
srcDown: resolveUrl( this.prefixUrl, navImages.rotateright.DOWN ),
|
|
|
|
onRelease: onRotateRightHandler,
|
|
|
|
onFocus: onFocusHandler,
|
|
|
|
onBlur: onBlurHandler
|
|
|
|
}));
|
2018-04-04 13:31:18 +03:00
|
|
|
}
|
2014-02-21 00:57:39 +04:00
|
|
|
|
2018-04-04 13:31:18 +03:00
|
|
|
if ( this.showFlipControl ) {
|
|
|
|
buttons.push( this.flipButton = new $.Button({
|
|
|
|
element: this.flipButton ? $.getElement( this.flipButton ) : null,
|
|
|
|
clickTimeThreshold: this.clickTimeThreshold,
|
|
|
|
clickDistThreshold: this.clickDistThreshold,
|
|
|
|
tooltip: $.getString( "Tooltips.Flip" ),
|
|
|
|
srcRest: resolveUrl( this.prefixUrl, navImages.flip.REST ),
|
|
|
|
srcGroup: resolveUrl( this.prefixUrl, navImages.flip.GROUP ),
|
|
|
|
srcHover: resolveUrl( this.prefixUrl, navImages.flip.HOVER ),
|
|
|
|
srcDown: resolveUrl( this.prefixUrl, navImages.flip.DOWN ),
|
|
|
|
onRelease: onFlipHandler,
|
|
|
|
onFocus: onFocusHandler,
|
|
|
|
onBlur: onBlurHandler
|
|
|
|
}));
|
2014-03-03 20:28:28 +04:00
|
|
|
}
|
2014-02-21 00:57:39 +04:00
|
|
|
|
2014-04-07 22:11:33 +04:00
|
|
|
if ( useGroup ) {
|
2012-04-11 01:02:24 +04:00
|
|
|
this.buttons = new $.ButtonGroup({
|
|
|
|
buttons: buttons,
|
|
|
|
clickTimeThreshold: this.clickTimeThreshold,
|
|
|
|
clickDistThreshold: this.clickDistThreshold
|
|
|
|
});
|
|
|
|
|
|
|
|
this.navControl = this.buttons.element;
|
|
|
|
this.addHandler( 'open', $.delegate( this, lightUp ) );
|
|
|
|
|
|
|
|
if( this.toolbar ){
|
2013-06-19 21:33:25 +04:00
|
|
|
this.toolbar.addControl(
|
|
|
|
this.navControl,
|
2016-03-09 18:54:06 +03:00
|
|
|
{anchor: this.navigationControlAnchor || $.ControlAnchor.TOP_LEFT}
|
2012-04-11 01:02:24 +04:00
|
|
|
);
|
2014-04-07 22:11:33 +04:00
|
|
|
} else {
|
2013-06-19 21:33:25 +04:00
|
|
|
this.addControl(
|
|
|
|
this.navControl,
|
2013-12-09 22:04:39 +04:00
|
|
|
{anchor: this.navigationControlAnchor || $.ControlAnchor.TOP_LEFT}
|
2012-04-11 01:02:24 +04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2012-06-05 15:52:00 +04:00
|
|
|
}
|
2013-02-14 04:44:23 +04:00
|
|
|
return this;
|
2012-06-05 15:52:00 +04:00
|
|
|
},
|
2014-07-18 03:24:28 +04:00
|
|
|
|
2013-10-10 23:25:11 +04:00
|
|
|
/**
|
2013-10-10 23:27:49 +04:00
|
|
|
* Gets the active page of a sequence
|
2013-10-10 23:25:11 +04:00
|
|
|
* @function
|
|
|
|
* @return {Number}
|
|
|
|
*/
|
2014-04-07 22:11:33 +04:00
|
|
|
currentPage: function() {
|
2014-11-15 04:19:04 +03:00
|
|
|
return this._sequenceIndex;
|
2014-04-07 22:11:33 +04:00
|
|
|
},
|
2013-10-09 04:07:49 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @function
|
|
|
|
* @return {OpenSeadragon.Viewer} Chainable.
|
2013-11-22 00:19:07 +04:00
|
|
|
* @fires OpenSeadragon.Viewer.event:page
|
2013-10-09 04:07:49 +04:00
|
|
|
*/
|
|
|
|
goToPage: function( page ){
|
2014-11-15 04:19:04 +03:00
|
|
|
if( this.tileSources && page >= 0 && page < this.tileSources.length ){
|
|
|
|
this._sequenceIndex = page;
|
2013-10-09 04:07:49 +04:00
|
|
|
|
2013-10-10 23:25:11 +04:00
|
|
|
this._updateSequenceButtons( page );
|
2012-06-05 15:52:00 +04:00
|
|
|
|
2013-03-26 17:02:34 +04:00
|
|
|
this.open( this.tileSources[ page ] );
|
2013-02-14 04:44:23 +04:00
|
|
|
|
2013-11-20 00:13:38 +04:00
|
|
|
if( this.referenceStrip ){
|
|
|
|
this.referenceStrip.setFocus( page );
|
|
|
|
}
|
2017-10-24 16:18:57 +03:00
|
|
|
|
2013-11-20 00:13:38 +04:00
|
|
|
/**
|
2013-11-22 00:19:07 +04:00
|
|
|
* Raised when the page is changed on a viewer configured with multiple image sources (see {@link OpenSeadragon.Viewer#goToPage}).
|
2013-11-20 00:13:38 +04:00
|
|
|
*
|
|
|
|
* @event page
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {Object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
|
|
|
* @property {Number} page - The page index.
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
|
|
|
this.raiseEvent( 'page', { page: page } );
|
2012-10-13 07:40:59 +04:00
|
|
|
}
|
2013-11-20 00:13:38 +04:00
|
|
|
|
2013-02-14 04:44:23 +04:00
|
|
|
return this;
|
2013-06-28 23:46:31 +04:00
|
|
|
},
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2014-01-31 00:38:37 +04:00
|
|
|
/**
|
|
|
|
* Adds an html element as an overlay to the current viewport. Useful for
|
|
|
|
* highlighting words or areas of interest on an image or other zoomable
|
2014-03-15 19:20:33 +04:00
|
|
|
* interface. The overlays added via this method are removed when the viewport
|
|
|
|
* is closed which include when changing page.
|
2014-01-31 00:38:37 +04:00
|
|
|
* @method
|
|
|
|
* @param {Element|String|Object} element - A reference to an element or an id for
|
2016-03-25 23:49:58 +03:00
|
|
|
* the element which will be overlayed. Or an Object specifying the configuration for the overlay.
|
|
|
|
* If using an object, see {@link OpenSeadragon.Overlay} for a list of
|
|
|
|
* all available options.
|
2014-01-31 00:38:37 +04:00
|
|
|
* @param {OpenSeadragon.Point|OpenSeadragon.Rect} location - The point or
|
2016-03-04 21:26:53 +03:00
|
|
|
* rectangle which will be overlayed. This is a viewport relative location.
|
2016-03-22 22:50:48 +03:00
|
|
|
* @param {OpenSeadragon.Placement} placement - The position of the
|
2014-01-31 00:38:37 +04:00
|
|
|
* viewport which the location coordinates will be treated as relative
|
|
|
|
* to.
|
|
|
|
* @param {function} onDraw - If supplied the callback is called when the overlay
|
|
|
|
* needs to be drawn. It it the responsibility of the callback to do any drawing/positioning.
|
|
|
|
* It is passed position, size and element.
|
|
|
|
* @return {OpenSeadragon.Viewer} Chainable.
|
|
|
|
* @fires OpenSeadragon.Viewer.event:add-overlay
|
|
|
|
*/
|
|
|
|
addOverlay: function( element, location, placement, onDraw ) {
|
|
|
|
var options;
|
|
|
|
if( $.isPlainObject( element ) ){
|
|
|
|
options = element;
|
|
|
|
} else {
|
|
|
|
options = {
|
|
|
|
element: element,
|
|
|
|
location: location,
|
|
|
|
placement: placement,
|
|
|
|
onDraw: onDraw
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2014-03-15 19:20:33 +04:00
|
|
|
element = $.getElement( options.element );
|
2014-01-31 00:38:37 +04:00
|
|
|
|
|
|
|
if ( getOverlayIndex( this.currentOverlays, element ) >= 0 ) {
|
|
|
|
// they're trying to add a duplicate overlay
|
|
|
|
return this;
|
|
|
|
}
|
2014-11-21 02:33:13 +03:00
|
|
|
|
|
|
|
var overlay = getOverlayObject( this, options);
|
|
|
|
this.currentOverlays.push(overlay);
|
|
|
|
overlay.drawHTML( this.overlaysContainer, this.viewport );
|
|
|
|
|
2014-01-31 00:38:37 +04:00
|
|
|
/**
|
|
|
|
* Raised when an overlay is added to the viewer (see {@link OpenSeadragon.Viewer#addOverlay}).
|
|
|
|
*
|
|
|
|
* @event add-overlay
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
|
|
|
* @property {Element} element - The overlay element.
|
|
|
|
* @property {OpenSeadragon.Point|OpenSeadragon.Rect} location
|
2016-03-22 22:50:48 +03:00
|
|
|
* @property {OpenSeadragon.Placement} placement
|
2014-01-31 00:38:37 +04:00
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
|
|
|
this.raiseEvent( 'add-overlay', {
|
|
|
|
element: element,
|
|
|
|
location: options.location,
|
|
|
|
placement: options.placement
|
|
|
|
});
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the overlay represented by the reference to the element or
|
|
|
|
* element id moving it to the new location, relative to the new placement.
|
|
|
|
* @method
|
2015-06-30 20:58:51 +03:00
|
|
|
* @param {Element|String} element - A reference to an element or an id for
|
|
|
|
* the element which is overlayed.
|
2014-01-31 00:38:37 +04:00
|
|
|
* @param {OpenSeadragon.Point|OpenSeadragon.Rect} location - The point or
|
2016-03-04 21:26:53 +03:00
|
|
|
* rectangle which will be overlayed. This is a viewport relative location.
|
2016-03-22 22:50:48 +03:00
|
|
|
* @param {OpenSeadragon.Placement} placement - The position of the
|
2014-01-31 00:38:37 +04:00
|
|
|
* viewport which the location coordinates will be treated as relative
|
|
|
|
* to.
|
|
|
|
* @return {OpenSeadragon.Viewer} Chainable.
|
|
|
|
* @fires OpenSeadragon.Viewer.event:update-overlay
|
|
|
|
*/
|
|
|
|
updateOverlay: function( element, location, placement ) {
|
|
|
|
var i;
|
|
|
|
|
|
|
|
element = $.getElement( element );
|
|
|
|
i = getOverlayIndex( this.currentOverlays, element );
|
|
|
|
|
|
|
|
if ( i >= 0 ) {
|
|
|
|
this.currentOverlays[ i ].update( location, placement );
|
|
|
|
THIS[ this.hash ].forceRedraw = true;
|
|
|
|
/**
|
|
|
|
* Raised when an overlay's location or placement changes
|
|
|
|
* (see {@link OpenSeadragon.Viewer#updateOverlay}).
|
|
|
|
*
|
|
|
|
* @event update-overlay
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the
|
|
|
|
* Viewer which raised the event.
|
|
|
|
* @property {Element} element
|
|
|
|
* @property {OpenSeadragon.Point|OpenSeadragon.Rect} location
|
2016-03-22 22:50:48 +03:00
|
|
|
* @property {OpenSeadragon.Placement} placement
|
2014-01-31 00:38:37 +04:00
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
|
|
|
this.raiseEvent( 'update-overlay', {
|
|
|
|
element: element,
|
|
|
|
location: location,
|
|
|
|
placement: placement
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes an overlay identified by the reference element or element id
|
|
|
|
* and schedules an update.
|
|
|
|
* @method
|
|
|
|
* @param {Element|String} element - A reference to the element or an
|
|
|
|
* element id which represent the ovelay content to be removed.
|
|
|
|
* @return {OpenSeadragon.Viewer} Chainable.
|
|
|
|
* @fires OpenSeadragon.Viewer.event:remove-overlay
|
|
|
|
*/
|
|
|
|
removeOverlay: function( element ) {
|
|
|
|
var i;
|
|
|
|
|
|
|
|
element = $.getElement( element );
|
|
|
|
i = getOverlayIndex( this.currentOverlays, element );
|
|
|
|
|
|
|
|
if ( i >= 0 ) {
|
|
|
|
this.currentOverlays[ i ].destroy();
|
|
|
|
this.currentOverlays.splice( i, 1 );
|
|
|
|
THIS[ this.hash ].forceRedraw = true;
|
|
|
|
/**
|
|
|
|
* Raised when an overlay is removed from the viewer
|
|
|
|
* (see {@link OpenSeadragon.Viewer#removeOverlay}).
|
|
|
|
*
|
|
|
|
* @event remove-overlay
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the
|
|
|
|
* Viewer which raised the event.
|
|
|
|
* @property {Element} element - The overlay element.
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
|
|
|
this.raiseEvent( 'remove-overlay', {
|
|
|
|
element: element
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes all currently configured Overlays from this Viewer and schedules
|
|
|
|
* an update.
|
|
|
|
* @method
|
|
|
|
* @return {OpenSeadragon.Viewer} Chainable.
|
|
|
|
* @fires OpenSeadragon.Viewer.event:clear-overlay
|
|
|
|
*/
|
|
|
|
clearOverlays: function() {
|
|
|
|
while ( this.currentOverlays.length > 0 ) {
|
|
|
|
this.currentOverlays.pop().destroy();
|
|
|
|
}
|
|
|
|
THIS[ this.hash ].forceRedraw = true;
|
|
|
|
/**
|
|
|
|
* Raised when all overlays are removed from the viewer (see {@link OpenSeadragon.Drawer#clearOverlays}).
|
|
|
|
*
|
|
|
|
* @event clear-overlay
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
|
|
|
this.raiseEvent( 'clear-overlay', {} );
|
|
|
|
return this;
|
|
|
|
},
|
2016-02-23 20:22:53 +03:00
|
|
|
|
2016-02-18 01:43:53 +03:00
|
|
|
/**
|
|
|
|
* Finds an overlay identified by the reference element or element id
|
2016-02-20 00:45:33 +03:00
|
|
|
* and returns it as an object, return null if not found.
|
2016-02-18 01:43:53 +03:00
|
|
|
* @method
|
|
|
|
* @param {Element|String} element - A reference to the element or an
|
2016-02-23 20:22:53 +03:00
|
|
|
* element id which represents the overlay content.
|
2016-02-20 00:45:33 +03:00
|
|
|
* @return {OpenSeadragon.Overlay} the matching overlay or null if none found.
|
2016-02-18 01:43:53 +03:00
|
|
|
*/
|
|
|
|
getOverlayById: function( element ) {
|
|
|
|
var i;
|
2014-01-31 00:38:37 +04:00
|
|
|
|
2016-02-18 01:43:53 +03:00
|
|
|
element = $.getElement( element );
|
2016-02-23 20:22:53 +03:00
|
|
|
i = getOverlayIndex( this.currentOverlays, element );
|
|
|
|
|
2017-01-08 17:52:57 +03:00
|
|
|
if (i >= 0) {
|
2016-02-18 01:43:53 +03:00
|
|
|
return this.currentOverlays[i];
|
|
|
|
} else {
|
2016-02-20 00:45:33 +03:00
|
|
|
return null;
|
2016-02-18 01:43:53 +03:00
|
|
|
}
|
|
|
|
},
|
2016-02-23 20:22:53 +03:00
|
|
|
|
2013-10-10 23:27:49 +04:00
|
|
|
/**
|
|
|
|
* Updates the sequence buttons.
|
2013-11-16 10:19:53 +04:00
|
|
|
* @function OpenSeadragon.Viewer.prototype._updateSequenceButtons
|
2013-10-10 23:27:49 +04:00
|
|
|
* @private
|
|
|
|
* @param {Number} Sequence Value
|
2013-10-10 23:35:49 +04:00
|
|
|
*/
|
2014-04-07 22:11:33 +04:00
|
|
|
_updateSequenceButtons: function( page ) {
|
2013-10-10 23:27:49 +04:00
|
|
|
|
2014-04-07 22:11:33 +04:00
|
|
|
if ( this.nextButton ) {
|
2014-11-15 04:19:04 +03:00
|
|
|
if(!this.tileSources || this.tileSources.length - 1 === page) {
|
2013-10-10 23:27:49 +04:00
|
|
|
//Disable next button
|
2014-04-07 22:11:33 +04:00
|
|
|
if ( !this.navPrevNextWrap ) {
|
2013-10-10 23:27:49 +04:00
|
|
|
this.nextButton.disable();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.nextButton.enable();
|
|
|
|
}
|
|
|
|
}
|
2014-04-07 22:11:33 +04:00
|
|
|
if ( this.previousButton ) {
|
|
|
|
if ( page > 0 ) {
|
2013-10-10 23:27:49 +04:00
|
|
|
//Enable previous button
|
|
|
|
this.previousButton.enable();
|
|
|
|
} else {
|
2014-04-07 22:11:33 +04:00
|
|
|
if ( !this.navPrevNextWrap ) {
|
2013-10-10 23:27:49 +04:00
|
|
|
this.previousButton.disable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2014-07-18 03:24:28 +04:00
|
|
|
|
2013-06-28 23:46:31 +04:00
|
|
|
/**
|
|
|
|
* Display a message in the viewport
|
2013-11-16 10:19:53 +04:00
|
|
|
* @function OpenSeadragon.Viewer.prototype._showMessage
|
2013-07-01 21:43:48 +04:00
|
|
|
* @private
|
2013-06-28 23:46:31 +04:00
|
|
|
* @param {String} text message
|
|
|
|
*/
|
2013-07-01 21:43:48 +04:00
|
|
|
_showMessage: function ( message ) {
|
|
|
|
this._hideMessage();
|
2013-07-01 20:58:22 +04:00
|
|
|
|
2013-07-01 21:43:48 +04:00
|
|
|
var div = $.makeNeutralElement( "div" );
|
2013-06-28 23:46:31 +04:00
|
|
|
div.appendChild( document.createTextNode( message ) );
|
|
|
|
|
2013-07-01 21:43:48 +04:00
|
|
|
this.messageDiv = $.makeCenteredNode( div );
|
|
|
|
|
2013-07-02 02:26:33 +04:00
|
|
|
$.addClass(this.messageDiv, "openseadragon-message");
|
|
|
|
|
2013-07-01 21:43:48 +04:00
|
|
|
this.container.appendChild( this.messageDiv );
|
2013-06-28 23:46:31 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hide any currently displayed viewport message
|
2013-11-16 10:19:53 +04:00
|
|
|
* @function OpenSeadragon.Viewer.prototype._hideMessage
|
2013-07-01 21:43:48 +04:00
|
|
|
* @private
|
2013-06-28 23:46:31 +04:00
|
|
|
*/
|
2013-07-01 21:43:48 +04:00
|
|
|
_hideMessage: function () {
|
2013-06-28 23:46:31 +04:00
|
|
|
var div = this.messageDiv;
|
|
|
|
if (div) {
|
2013-07-01 21:43:48 +04:00
|
|
|
div.parentNode.removeChild(div);
|
2013-06-28 23:46:31 +04:00
|
|
|
delete this.messageDiv;
|
|
|
|
}
|
2014-04-03 19:50:25 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets this viewer's gesture settings for the given pointer device type.
|
|
|
|
* @method
|
2014-04-15 05:17:18 +04:00
|
|
|
* @param {String} type - The pointer device type to get the gesture settings for ("mouse", "touch", "pen", etc.).
|
2014-04-03 19:50:25 +04:00
|
|
|
* @return {OpenSeadragon.GestureSettings}
|
|
|
|
*/
|
|
|
|
gestureSettingsByDeviceType: function ( type ) {
|
2014-04-15 05:17:18 +04:00
|
|
|
switch ( type ) {
|
|
|
|
case 'mouse':
|
|
|
|
return this.gestureSettingsMouse;
|
|
|
|
case 'touch':
|
|
|
|
return this.gestureSettingsTouch;
|
|
|
|
case 'pen':
|
|
|
|
return this.gestureSettingsPen;
|
|
|
|
default:
|
|
|
|
return this.gestureSettingsUnknown;
|
2014-04-03 19:50:25 +04:00
|
|
|
}
|
2014-11-21 02:33:13 +03:00
|
|
|
},
|
2014-04-03 19:50:25 +04:00
|
|
|
|
2014-11-21 02:33:13 +03:00
|
|
|
// private
|
|
|
|
_drawOverlays: function() {
|
|
|
|
var i,
|
|
|
|
length = this.currentOverlays.length;
|
|
|
|
for ( i = 0; i < length; i++ ) {
|
|
|
|
this.currentOverlays[ i ].drawHTML( this.overlaysContainer, this.viewport );
|
|
|
|
}
|
2015-09-24 00:19:02 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Cancel the "in flight" images.
|
|
|
|
*/
|
|
|
|
_cancelPendingImages: function() {
|
|
|
|
this._loadQueue = [];
|
2017-06-06 19:21:14 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2017-07-01 10:57:36 +03:00
|
|
|
* Removes the reference strip and disables displaying it.
|
2017-06-06 19:21:14 +03:00
|
|
|
* @function
|
|
|
|
*/
|
2017-07-01 10:57:36 +03:00
|
|
|
removeReferenceStrip: function() {
|
|
|
|
this.showReferenceStrip = false;
|
2017-06-06 19:21:14 +03:00
|
|
|
|
2017-06-24 18:58:19 +03:00
|
|
|
if (this.referenceStrip) {
|
|
|
|
this.referenceStrip.destroy();
|
|
|
|
this.referenceStrip = null;
|
|
|
|
}
|
2017-06-06 19:21:14 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2017-07-01 10:57:36 +03:00
|
|
|
* Enables and displays the reference strip based on the currently set tileSources.
|
2017-07-05 19:42:10 +03:00
|
|
|
* Works only when the Viewer has sequenceMode set to true.
|
2017-06-06 19:21:14 +03:00
|
|
|
* @function
|
|
|
|
*/
|
|
|
|
addReferenceStrip: function() {
|
|
|
|
this.showReferenceStrip = true;
|
|
|
|
|
|
|
|
if (this.sequenceMode) {
|
|
|
|
if (this.referenceStrip) {
|
2017-07-01 10:57:36 +03:00
|
|
|
return;
|
2017-06-06 19:21:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.tileSources.length && this.tileSources.length > 1) {
|
|
|
|
this.referenceStrip = new $.ReferenceStrip({
|
|
|
|
id: this.referenceStripElement,
|
|
|
|
position: this.referenceStripPosition,
|
|
|
|
sizeRatio: this.referenceStripSizeRatio,
|
|
|
|
scroll: this.referenceStripScroll,
|
|
|
|
height: this.referenceStripHeight,
|
|
|
|
width: this.referenceStripWidth,
|
|
|
|
tileSources: this.tileSources,
|
|
|
|
prefixUrl: this.prefixUrl,
|
|
|
|
viewer: this
|
|
|
|
});
|
|
|
|
|
|
|
|
this.referenceStrip.setFocus( this._sequenceIndex );
|
|
|
|
}
|
2017-07-01 10:57:36 +03:00
|
|
|
} else {
|
|
|
|
$.console.warn('Attempting to display a reference strip while "sequenceMode" is off.');
|
2017-06-06 19:21:14 +03:00
|
|
|
}
|
2014-11-21 02:33:13 +03:00
|
|
|
}
|
2011-12-15 03:22:02 +04:00
|
|
|
});
|
2011-12-06 07:50:25 +04:00
|
|
|
|
2013-07-31 22:00:16 +04:00
|
|
|
|
|
|
|
/**
|
2013-08-02 20:40:55 +04:00
|
|
|
* _getSafeElemSize is like getElementSize(), but refuses to return 0 for x or y,
|
2014-10-30 02:11:21 +03:00
|
|
|
* which was causing some calling operations to return NaN.
|
2013-08-02 20:40:55 +04:00
|
|
|
* @returns {Point}
|
2013-07-31 22:00:16 +04:00
|
|
|
* @private
|
|
|
|
*/
|
2013-07-31 23:01:46 +04:00
|
|
|
function _getSafeElemSize (oElement) {
|
2013-08-01 21:11:33 +04:00
|
|
|
oElement = $.getElement( oElement );
|
2013-07-31 23:01:46 +04:00
|
|
|
|
2013-08-01 21:11:33 +04:00
|
|
|
return new $.Point(
|
|
|
|
(oElement.clientWidth === 0 ? 1 : oElement.clientWidth),
|
|
|
|
(oElement.clientHeight === 0 ? 1 : oElement.clientHeight)
|
|
|
|
);
|
2013-07-31 22:00:16 +04:00
|
|
|
}
|
|
|
|
|
2017-05-09 21:55:23 +03:00
|
|
|
|
2013-12-09 18:26:36 +04:00
|
|
|
/**
|
|
|
|
* @function
|
|
|
|
* @private
|
|
|
|
*/
|
2016-07-28 18:35:43 +03:00
|
|
|
function getTileSourceImplementation( viewer, tileSource, imgOptions, successCallback,
|
2014-01-06 04:20:45 +04:00
|
|
|
failCallback ) {
|
2013-12-09 18:26:36 +04:00
|
|
|
var _this = viewer;
|
|
|
|
|
|
|
|
//allow plain xml strings or json strings to be parsed here
|
|
|
|
if ( $.type( tileSource ) == 'string' ) {
|
2016-08-10 00:36:12 +03:00
|
|
|
//xml should start with "<" and end with ">"
|
|
|
|
if ( tileSource.match( /^\s*<.*>\s*$/ ) ) {
|
2013-12-09 18:26:36 +04:00
|
|
|
tileSource = $.parseXml( tileSource );
|
2016-08-10 00:36:12 +03:00
|
|
|
//json should start with "{" or "[" and end with "}" or "]"
|
|
|
|
} else if ( tileSource.match(/^\s*[\{\[].*[\}\]]\s*$/ ) ) {
|
2017-05-11 00:51:59 +03:00
|
|
|
try {
|
|
|
|
var tileSourceJ = $.parseJSON(tileSource);
|
|
|
|
tileSource = tileSourceJ;
|
|
|
|
} catch (e) {
|
|
|
|
//tileSource = tileSource;
|
|
|
|
}
|
2013-12-09 18:26:36 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-06 06:04:21 +03:00
|
|
|
function waitUntilReady(tileSource, originalTileSource) {
|
|
|
|
if (tileSource.ready) {
|
|
|
|
successCallback(tileSource);
|
|
|
|
} else {
|
|
|
|
tileSource.addHandler('ready', function () {
|
|
|
|
successCallback(tileSource);
|
|
|
|
});
|
|
|
|
tileSource.addHandler('open-failed', function (event) {
|
|
|
|
failCallback({
|
|
|
|
message: event.message,
|
|
|
|
source: originalTileSource
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-09 18:26:36 +04:00
|
|
|
setTimeout( function() {
|
|
|
|
if ( $.type( tileSource ) == 'string' ) {
|
|
|
|
//If its still a string it means it must be a url at this point
|
2015-01-03 02:45:46 +03:00
|
|
|
tileSource = new $.TileSource({
|
|
|
|
url: tileSource,
|
2016-07-28 18:35:43 +03:00
|
|
|
crossOriginPolicy: imgOptions.crossOriginPolicy !== undefined ?
|
|
|
|
imgOptions.crossOriginPolicy : viewer.crossOriginPolicy,
|
2015-01-03 02:45:46 +03:00
|
|
|
ajaxWithCredentials: viewer.ajaxWithCredentials,
|
2016-11-08 20:27:30 +03:00
|
|
|
ajaxHeaders: viewer.ajaxHeaders,
|
2015-11-03 02:35:11 +03:00
|
|
|
useCanvas: viewer.useCanvas,
|
2015-01-03 02:45:46 +03:00
|
|
|
success: function( event ) {
|
|
|
|
successCallback( event.tileSource );
|
|
|
|
}
|
2013-12-09 18:26:36 +04:00
|
|
|
});
|
|
|
|
tileSource.addHandler( 'open-failed', function( event ) {
|
|
|
|
failCallback( event );
|
|
|
|
} );
|
|
|
|
|
2015-11-01 21:25:25 +03:00
|
|
|
} else if ($.isPlainObject(tileSource) || tileSource.nodeType) {
|
2016-07-28 18:35:43 +03:00
|
|
|
if (tileSource.crossOriginPolicy === undefined &&
|
|
|
|
(imgOptions.crossOriginPolicy !== undefined || viewer.crossOriginPolicy !== undefined)) {
|
|
|
|
tileSource.crossOriginPolicy = imgOptions.crossOriginPolicy !== undefined ?
|
|
|
|
imgOptions.crossOriginPolicy : viewer.crossOriginPolicy;
|
2015-11-01 21:25:25 +03:00
|
|
|
}
|
2015-01-03 02:45:46 +03:00
|
|
|
if (tileSource.ajaxWithCredentials === undefined) {
|
|
|
|
tileSource.ajaxWithCredentials = viewer.ajaxWithCredentials;
|
|
|
|
}
|
2015-11-03 02:35:11 +03:00
|
|
|
if (tileSource.useCanvas === undefined) {
|
|
|
|
tileSource.useCanvas = viewer.useCanvas;
|
|
|
|
}
|
2015-01-03 02:45:46 +03:00
|
|
|
|
2013-12-09 18:26:36 +04:00
|
|
|
if ( $.isFunction( tileSource.getTileUrl ) ) {
|
|
|
|
//Custom tile source
|
|
|
|
var customTileSource = new $.TileSource( tileSource );
|
|
|
|
customTileSource.getTileUrl = tileSource.getTileUrl;
|
|
|
|
successCallback( customTileSource );
|
|
|
|
} else {
|
|
|
|
//inline configuration
|
|
|
|
var $TileSource = $.TileSource.determineType( _this, tileSource );
|
|
|
|
if ( !$TileSource ) {
|
|
|
|
failCallback( {
|
|
|
|
message: "Unable to load TileSource",
|
|
|
|
source: tileSource
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var options = $TileSource.prototype.configure.apply( _this, [ tileSource ] );
|
2015-11-06 06:04:21 +03:00
|
|
|
waitUntilReady(new $TileSource(options), tileSource);
|
2013-12-09 18:26:36 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//can assume it's already a tile source implementation
|
2015-11-06 06:04:21 +03:00
|
|
|
waitUntilReady(tileSource, tileSource);
|
2013-12-09 18:26:36 +04:00
|
|
|
}
|
2015-11-01 18:23:02 +03:00
|
|
|
});
|
2013-12-09 18:26:36 +04:00
|
|
|
}
|
|
|
|
|
2014-01-31 00:38:37 +04:00
|
|
|
function getOverlayObject( viewer, overlay ) {
|
2014-03-15 19:20:33 +04:00
|
|
|
if ( overlay instanceof $.Overlay ) {
|
2014-01-31 00:38:37 +04:00
|
|
|
return overlay;
|
|
|
|
}
|
2012-04-03 11:08:27 +04:00
|
|
|
|
2014-03-15 19:20:33 +04:00
|
|
|
var element = null;
|
|
|
|
if ( overlay.element ) {
|
|
|
|
element = $.getElement( overlay.element );
|
|
|
|
} else {
|
|
|
|
var id = overlay.id ?
|
|
|
|
overlay.id :
|
|
|
|
"openseadragon-overlay-" + Math.floor( Math.random() * 10000000 );
|
|
|
|
|
|
|
|
element = $.getElement( overlay.id );
|
|
|
|
if ( !element ) {
|
|
|
|
element = document.createElement( "a" );
|
|
|
|
element.href = "#/overlay/" + id;
|
|
|
|
}
|
|
|
|
element.id = id;
|
|
|
|
$.addClass( element, overlay.className ?
|
|
|
|
overlay.className :
|
|
|
|
"openseadragon-overlay"
|
|
|
|
);
|
2014-01-31 00:38:37 +04:00
|
|
|
}
|
|
|
|
|
2014-03-15 19:20:33 +04:00
|
|
|
var location = overlay.location;
|
2016-03-31 20:25:59 +03:00
|
|
|
var width = overlay.width;
|
|
|
|
var height = overlay.height;
|
|
|
|
if (!location) {
|
|
|
|
var x = overlay.x;
|
|
|
|
var y = overlay.y;
|
|
|
|
if (overlay.px !== undefined) {
|
|
|
|
var rect = viewer.viewport.imageToViewportRectangle(new $.Rect(
|
|
|
|
overlay.px,
|
|
|
|
overlay.py,
|
|
|
|
width || 0,
|
|
|
|
height || 0));
|
|
|
|
x = rect.x;
|
|
|
|
y = rect.y;
|
|
|
|
width = width !== undefined ? rect.width : undefined;
|
|
|
|
height = height !== undefined ? rect.height : undefined;
|
2014-03-15 19:20:33 +04:00
|
|
|
}
|
2016-03-31 20:25:59 +03:00
|
|
|
location = new $.Point(x, y);
|
2014-01-31 00:38:37 +04:00
|
|
|
}
|
|
|
|
|
2014-03-15 19:20:33 +04:00
|
|
|
var placement = overlay.placement;
|
2016-03-22 22:50:48 +03:00
|
|
|
if (placement && $.type(placement) === "string") {
|
|
|
|
placement = $.Placement[overlay.placement.toUpperCase()];
|
2014-01-31 00:38:37 +04:00
|
|
|
}
|
2014-03-15 19:20:33 +04:00
|
|
|
|
|
|
|
return new $.Overlay({
|
|
|
|
element: element,
|
|
|
|
location: location,
|
|
|
|
placement: placement,
|
2014-03-20 23:39:31 +04:00
|
|
|
onDraw: overlay.onDraw,
|
2016-03-25 23:49:58 +03:00
|
|
|
checkResize: overlay.checkResize,
|
2016-03-31 20:25:59 +03:00
|
|
|
width: width,
|
|
|
|
height: height,
|
2016-03-29 00:06:59 +03:00
|
|
|
rotationMode: overlay.rotationMode
|
2014-03-15 19:20:33 +04:00
|
|
|
});
|
2014-01-31 00:38:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @private
|
|
|
|
* @inner
|
2014-03-15 19:20:33 +04:00
|
|
|
* Determines the index of the given overlay in the given overlays array.
|
2014-01-31 00:38:37 +04:00
|
|
|
*/
|
|
|
|
function getOverlayIndex( overlays, element ) {
|
|
|
|
var i;
|
|
|
|
for ( i = overlays.length - 1; i >= 0; i-- ) {
|
2014-03-15 19:20:33 +04:00
|
|
|
if ( overlays[ i ].element === element ) {
|
2014-01-31 00:38:37 +04:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
2013-03-26 17:02:34 +04:00
|
|
|
|
2014-01-31 00:38:37 +04:00
|
|
|
return -1;
|
|
|
|
}
|
2012-04-03 11:08:27 +04:00
|
|
|
|
2011-12-08 06:10:13 +04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Schedulers provide the general engine for animation
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2013-06-19 20:58:09 +04:00
|
|
|
function scheduleUpdate( viewer, updateFunc ){
|
2013-04-27 05:48:48 +04:00
|
|
|
return $.requestAnimationFrame( function(){
|
|
|
|
updateFunc( viewer );
|
|
|
|
} );
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-08 06:10:13 +04:00
|
|
|
|
2012-04-03 11:08:27 +04:00
|
|
|
|
2011-12-08 06:10:13 +04:00
|
|
|
//provides a sequence in the fade animation
|
|
|
|
function scheduleControlsFade( viewer ) {
|
2013-02-26 19:19:48 +04:00
|
|
|
$.requestAnimationFrame( function(){
|
2011-12-08 06:10:13 +04:00
|
|
|
updateControlsFade( viewer );
|
2013-02-26 19:19:48 +04:00
|
|
|
});
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-08 06:10:13 +04:00
|
|
|
|
2012-04-03 11:08:27 +04:00
|
|
|
|
2011-12-08 06:10:13 +04:00
|
|
|
//initiates an animation to hide the controls
|
|
|
|
function beginControlsAutoHide( viewer ) {
|
2012-03-01 17:38:15 +04:00
|
|
|
if ( !viewer.autoHideControls ) {
|
2011-12-08 06:10:13 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
viewer.controlsShouldFade = true;
|
2013-06-19 21:33:25 +04:00
|
|
|
viewer.controlsFadeBeginTime =
|
2013-06-21 00:15:04 +04:00
|
|
|
$.now() +
|
2012-03-01 17:38:15 +04:00
|
|
|
viewer.controlsFadeDelay;
|
2011-12-08 06:10:13 +04:00
|
|
|
|
|
|
|
window.setTimeout( function(){
|
|
|
|
scheduleControlsFade( viewer );
|
2012-03-01 17:38:15 +04:00
|
|
|
}, viewer.controlsFadeDelay );
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-08 06:10:13 +04:00
|
|
|
|
|
|
|
|
|
|
|
//determines if fade animation is done or continues the animation
|
|
|
|
function updateControlsFade( viewer ) {
|
|
|
|
var currentTime,
|
|
|
|
deltaTime,
|
|
|
|
opacity,
|
|
|
|
i;
|
|
|
|
if ( viewer.controlsShouldFade ) {
|
2013-06-21 00:15:04 +04:00
|
|
|
currentTime = $.now();
|
2011-12-08 06:10:13 +04:00
|
|
|
deltaTime = currentTime - viewer.controlsFadeBeginTime;
|
2012-03-01 17:38:15 +04:00
|
|
|
opacity = 1.0 - deltaTime / viewer.controlsFadeLength;
|
2011-12-08 06:10:13 +04:00
|
|
|
|
|
|
|
opacity = Math.min( 1.0, opacity );
|
|
|
|
opacity = Math.max( 0.0, opacity );
|
|
|
|
|
2011-12-13 02:22:01 +04:00
|
|
|
for ( i = viewer.controls.length - 1; i >= 0; i--) {
|
2013-03-15 18:59:47 +04:00
|
|
|
if (viewer.controls[ i ].autoFade) {
|
|
|
|
viewer.controls[ i ].setOpacity( opacity );
|
|
|
|
}
|
2011-12-08 06:10:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( opacity > 0 ) {
|
|
|
|
// fade again
|
2013-06-19 21:33:25 +04:00
|
|
|
scheduleControlsFade( viewer );
|
2011-12-08 06:10:13 +04:00
|
|
|
}
|
|
|
|
}
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-08 06:10:13 +04:00
|
|
|
|
2012-04-03 11:08:27 +04:00
|
|
|
|
2011-12-08 06:10:13 +04:00
|
|
|
//stop the fade animation on the controls and show them
|
|
|
|
function abortControlsAutoHide( viewer ) {
|
|
|
|
var i;
|
|
|
|
viewer.controlsShouldFade = false;
|
|
|
|
for ( i = viewer.controls.length - 1; i >= 0; i-- ) {
|
|
|
|
viewer.controls[ i ].setOpacity( 1.0 );
|
|
|
|
}
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-08 06:10:13 +04:00
|
|
|
|
|
|
|
|
2012-04-03 11:08:27 +04:00
|
|
|
|
2011-12-08 06:10:13 +04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Default view event handlers.
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2012-03-16 19:36:28 +04:00
|
|
|
function onFocus(){
|
|
|
|
abortControlsAutoHide( this );
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2012-03-16 19:36:28 +04:00
|
|
|
|
|
|
|
function onBlur(){
|
|
|
|
beginControlsAutoHide( this );
|
2013-06-19 21:33:25 +04:00
|
|
|
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2012-03-16 19:36:28 +04:00
|
|
|
|
2015-01-17 22:18:55 +03:00
|
|
|
function onCanvasKeyDown( event ) {
|
2018-03-06 17:51:22 +03:00
|
|
|
var canvasKeyDownEventArgs = {
|
|
|
|
originalEvent: event.originalEvent,
|
|
|
|
preventDefaultAction: event.preventDefaultAction,
|
|
|
|
preventVerticalPan: event.preventVerticalPan,
|
|
|
|
preventHorizontalPan: event.preventHorizontalPan
|
|
|
|
};
|
2018-03-07 20:28:20 +03:00
|
|
|
|
2018-03-07 12:32:31 +03:00
|
|
|
/**
|
|
|
|
* Raised when a keyboard key is pressed and the focus is on the {@link OpenSeadragon.Viewer#canvas} element.
|
|
|
|
*
|
|
|
|
* @event canvas-key
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
|
|
|
* @property {Object} originalEvent - The original DOM event.
|
|
|
|
* @property {Boolean} preventDefaultAction - Set to true to prevent default keyboard behaviour. Default: false.
|
|
|
|
* @property {Boolean} preventVerticalPan - Set to true to prevent keyboard vertical panning. Default: false.
|
|
|
|
* @property {Boolean} preventHorizontalPan - Set to true to prevent keyboard horizontal panning. Default: false.
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
|
|
|
|
2018-03-07 13:07:29 +03:00
|
|
|
this.raiseEvent('canvas-key', canvasKeyDownEventArgs);
|
2018-03-06 17:51:22 +03:00
|
|
|
|
|
|
|
if ( !canvasKeyDownEventArgs.preventDefaultAction && !event.ctrl && !event.alt && !event.meta ) {
|
2015-01-17 22:18:55 +03:00
|
|
|
switch( event.keyCode ){
|
|
|
|
case 38://up arrow
|
2018-03-06 17:51:22 +03:00
|
|
|
if (!canvasKeyDownEventArgs.preventVerticalPan) {
|
|
|
|
if ( event.shift ) {
|
2015-01-17 22:25:24 +03:00
|
|
|
this.viewport.zoomBy(1.1);
|
2018-03-06 17:51:22 +03:00
|
|
|
} else {
|
2017-12-14 19:10:10 +03:00
|
|
|
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(0, -this.pixelsPerArrowPress)));
|
2018-03-06 17:51:22 +03:00
|
|
|
}
|
|
|
|
this.viewport.applyConstraints();
|
2015-01-17 22:18:55 +03:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
case 40://down arrow
|
2018-03-06 17:51:22 +03:00
|
|
|
if (!canvasKeyDownEventArgs.preventVerticalPan) {
|
|
|
|
if ( event.shift ) {
|
2015-01-17 22:25:24 +03:00
|
|
|
this.viewport.zoomBy(0.9);
|
2018-03-06 17:51:22 +03:00
|
|
|
} else {
|
2017-12-14 19:10:10 +03:00
|
|
|
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(0, this.pixelsPerArrowPress)));
|
2018-03-06 17:51:22 +03:00
|
|
|
}
|
|
|
|
this.viewport.applyConstraints();
|
2015-01-17 22:18:55 +03:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
case 37://left arrow
|
2018-03-06 17:51:22 +03:00
|
|
|
if (!canvasKeyDownEventArgs.preventHorizontalPan) {
|
|
|
|
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(-this.pixelsPerArrowPress, 0)));
|
|
|
|
this.viewport.applyConstraints();
|
|
|
|
}
|
2015-01-17 22:18:55 +03:00
|
|
|
return false;
|
|
|
|
case 39://right arrow
|
2018-03-06 17:51:22 +03:00
|
|
|
if (!canvasKeyDownEventArgs.preventHorizontalPan) {
|
|
|
|
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(this.pixelsPerArrowPress, 0)));
|
|
|
|
this.viewport.applyConstraints();
|
|
|
|
}
|
2015-01-17 22:18:55 +03:00
|
|
|
return false;
|
|
|
|
default:
|
|
|
|
//console.log( 'navigator keycode %s', event.keyCode );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function onCanvasKeyPress( event ) {
|
2018-03-06 17:51:22 +03:00
|
|
|
var canvasKeyPressEventArgs = {
|
|
|
|
originalEvent: event.originalEvent,
|
|
|
|
preventDefaultAction: event.preventDefaultAction,
|
|
|
|
preventVerticalPan: event.preventVerticalPan,
|
|
|
|
preventHorizontalPan: event.preventHorizontalPan
|
|
|
|
};
|
2018-03-07 13:07:29 +03:00
|
|
|
|
2018-03-07 20:28:20 +03:00
|
|
|
// This event is documented in onCanvasKeyDown
|
2018-03-07 13:07:29 +03:00
|
|
|
this.raiseEvent('canvas-key', canvasKeyPressEventArgs);
|
2018-03-06 17:51:22 +03:00
|
|
|
|
|
|
|
if ( !canvasKeyPressEventArgs.preventDefaultAction && !event.ctrl && !event.alt && !event.meta ) {
|
2015-01-17 22:18:55 +03:00
|
|
|
switch( event.keyCode ){
|
2015-11-04 13:00:08 +03:00
|
|
|
case 43://=|+
|
2015-01-17 22:18:55 +03:00
|
|
|
case 61://=|+
|
2015-01-17 22:25:24 +03:00
|
|
|
this.viewport.zoomBy(1.1);
|
|
|
|
this.viewport.applyConstraints();
|
2015-01-17 22:18:55 +03:00
|
|
|
return false;
|
|
|
|
case 45://-|_
|
2015-01-17 22:25:24 +03:00
|
|
|
this.viewport.zoomBy(0.9);
|
|
|
|
this.viewport.applyConstraints();
|
2015-01-17 22:18:55 +03:00
|
|
|
return false;
|
|
|
|
case 48://0|)
|
2015-01-17 22:25:24 +03:00
|
|
|
this.viewport.goHome();
|
|
|
|
this.viewport.applyConstraints();
|
2015-01-17 22:18:55 +03:00
|
|
|
return false;
|
|
|
|
case 119://w
|
|
|
|
case 87://W
|
2018-03-06 17:51:22 +03:00
|
|
|
if (!canvasKeyPressEventArgs.preventVerticalPan) {
|
|
|
|
if ( event.shift ) {
|
|
|
|
this.viewport.zoomBy(1.1);
|
|
|
|
} else {
|
|
|
|
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(0, -40)));
|
|
|
|
}
|
|
|
|
this.viewport.applyConstraints();
|
|
|
|
}
|
|
|
|
return false;
|
2015-01-17 22:18:55 +03:00
|
|
|
case 115://s
|
|
|
|
case 83://S
|
2018-03-06 17:51:22 +03:00
|
|
|
if (!canvasKeyPressEventArgs.preventVerticalPan) {
|
|
|
|
if ( event.shift ) {
|
2015-01-17 22:25:24 +03:00
|
|
|
this.viewport.zoomBy(0.9);
|
2018-03-06 17:51:22 +03:00
|
|
|
} else {
|
2015-05-06 03:20:20 +03:00
|
|
|
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(0, 40)));
|
2018-03-06 17:51:22 +03:00
|
|
|
}
|
|
|
|
this.viewport.applyConstraints();
|
2015-01-17 22:18:55 +03:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
case 97://a
|
2018-03-06 17:51:22 +03:00
|
|
|
if (!canvasKeyPressEventArgs.preventHorizontalPan) {
|
|
|
|
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(-40, 0)));
|
|
|
|
this.viewport.applyConstraints();
|
|
|
|
}
|
2015-01-17 22:18:55 +03:00
|
|
|
return false;
|
|
|
|
case 100://d
|
2018-03-06 17:51:22 +03:00
|
|
|
if (!canvasKeyPressEventArgs.preventHorizontalPan) {
|
|
|
|
this.viewport.panBy(this.viewport.deltaPointsFromPixels(new $.Point(40, 0)));
|
|
|
|
this.viewport.applyConstraints();
|
|
|
|
}
|
2015-01-17 22:18:55 +03:00
|
|
|
return false;
|
2018-08-22 00:39:46 +03:00
|
|
|
case 114: //r - clockwise rotation
|
2018-04-10 13:51:06 +03:00
|
|
|
if(this.viewport.flipped){
|
2018-08-22 00:39:46 +03:00
|
|
|
this.viewport.setRotation($.positiveModulo(this.viewport.degrees - this.rotationIncrement, 360));
|
2018-04-04 13:31:18 +03:00
|
|
|
} else{
|
2018-08-22 00:39:46 +03:00
|
|
|
this.viewport.setRotation($.positiveModulo(this.viewport.degrees + this.rotationIncrement, 360));
|
2018-04-04 13:31:18 +03:00
|
|
|
}
|
|
|
|
this.viewport.applyConstraints();
|
|
|
|
return false;
|
2018-08-22 00:39:46 +03:00
|
|
|
case 82: //R - counterclockwise rotation
|
2018-04-10 13:51:06 +03:00
|
|
|
if(this.viewport.flipped){
|
2018-08-22 00:39:46 +03:00
|
|
|
this.viewport.setRotation($.positiveModulo(this.viewport.degrees + this.rotationIncrement, 360));
|
2018-04-06 13:52:10 +03:00
|
|
|
} else{
|
2018-08-22 00:39:46 +03:00
|
|
|
this.viewport.setRotation($.positiveModulo(this.viewport.degrees - this.rotationIncrement, 360));
|
2018-04-06 13:52:10 +03:00
|
|
|
}
|
|
|
|
this.viewport.applyConstraints();
|
|
|
|
return false;
|
2018-04-04 13:31:18 +03:00
|
|
|
case 102: //f
|
2018-04-11 13:25:46 +03:00
|
|
|
this.viewport.toggleFlip();
|
2018-04-04 13:31:18 +03:00
|
|
|
return false;
|
2015-01-17 22:18:55 +03:00
|
|
|
default:
|
2018-04-04 13:31:18 +03:00
|
|
|
// console.log( 'navigator keycode %s', event.keyCode );
|
2015-01-17 22:18:55 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-11 04:00:15 +04:00
|
|
|
function onCanvasClick( event ) {
|
2014-04-03 19:50:25 +04:00
|
|
|
var gestureSettings;
|
|
|
|
|
2015-01-17 22:18:55 +03:00
|
|
|
var haveKeyboardFocus = document.activeElement == this.canvas;
|
2014-12-05 01:06:33 +03:00
|
|
|
|
|
|
|
// If we don't have keyboard focus, request it.
|
|
|
|
if ( !haveKeyboardFocus ) {
|
2015-01-17 22:18:55 +03:00
|
|
|
this.canvas.focus();
|
2014-12-05 01:06:33 +03:00
|
|
|
}
|
2018-04-10 13:51:06 +03:00
|
|
|
if(this.viewport.flipped){
|
2018-04-04 13:31:18 +03:00
|
|
|
event.position.x = this.viewport.getContainerSize().x - event.position.x;
|
|
|
|
}
|
2014-12-05 01:06:33 +03:00
|
|
|
|
2017-03-14 18:08:52 +03:00
|
|
|
var canvasClickEventArgs = {
|
|
|
|
tracker: event.eventSource,
|
|
|
|
position: event.position,
|
|
|
|
quick: event.quick,
|
|
|
|
shift: event.shift,
|
|
|
|
originalEvent: event.originalEvent,
|
|
|
|
preventDefaultAction: event.preventDefaultAction
|
|
|
|
};
|
|
|
|
|
2013-11-16 10:19:53 +04:00
|
|
|
/**
|
2013-11-25 20:48:44 +04:00
|
|
|
* Raised when a mouse press/release or touch/remove occurs on the {@link OpenSeadragon.Viewer#canvas} element.
|
2013-11-22 00:19:07 +04:00
|
|
|
*
|
2013-11-16 10:19:53 +04:00
|
|
|
* @event canvas-click
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
|
|
|
* @property {OpenSeadragon.MouseTracker} tracker - A reference to the MouseTracker which originated this event.
|
|
|
|
* @property {OpenSeadragon.Point} position - The position of the event relative to the tracked element.
|
2014-04-22 20:23:56 +04:00
|
|
|
* @property {Boolean} quick - True only if the clickDistThreshold and clickTimeThreshold are both passed. Useful for differentiating between clicks and drags.
|
2013-11-16 10:19:53 +04:00
|
|
|
* @property {Boolean} shift - True if the shift key was pressed during this event.
|
|
|
|
* @property {Object} originalEvent - The original DOM event.
|
2017-03-14 21:23:07 +03:00
|
|
|
* @property {Boolean} preventDefaultAction - Set to true to prevent default click to zoom behaviour. Default: false.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
2013-11-16 10:19:53 +04:00
|
|
|
*/
|
2017-03-14 18:08:52 +03:00
|
|
|
this.raiseEvent( 'canvas-click', canvasClickEventArgs);
|
|
|
|
|
|
|
|
if ( !canvasClickEventArgs.preventDefaultAction && this.viewport && event.quick ) {
|
|
|
|
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
|
|
|
|
if ( gestureSettings.clickToZoom ) {
|
|
|
|
this.viewport.zoomBy(
|
|
|
|
event.shift ? 1.0 / this.zoomPerClick : this.zoomPerClick,
|
2018-03-16 13:29:16 +03:00
|
|
|
gestureSettings.zoomToRefPoint ? this.viewport.pointFromPixel( event.position, true ) : null
|
2017-03-14 18:08:52 +03:00
|
|
|
);
|
|
|
|
this.viewport.applyConstraints();
|
|
|
|
}
|
|
|
|
}
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-08 06:10:13 +04:00
|
|
|
|
2014-04-22 20:23:56 +04:00
|
|
|
function onCanvasDblClick( event ) {
|
|
|
|
var gestureSettings;
|
|
|
|
|
2017-08-21 23:38:44 +03:00
|
|
|
var canvasDblClickEventArgs = {
|
|
|
|
tracker: event.eventSource,
|
|
|
|
position: event.position,
|
|
|
|
shift: event.shift,
|
|
|
|
originalEvent: event.originalEvent,
|
|
|
|
preventDefaultAction: event.preventDefaultAction
|
|
|
|
};
|
|
|
|
|
2014-04-22 20:23:56 +04:00
|
|
|
/**
|
|
|
|
* Raised when a double mouse press/release or touch/remove occurs on the {@link OpenSeadragon.Viewer#canvas} element.
|
|
|
|
*
|
|
|
|
* @event canvas-double-click
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
|
|
|
* @property {OpenSeadragon.MouseTracker} tracker - A reference to the MouseTracker which originated this event.
|
|
|
|
* @property {OpenSeadragon.Point} position - The position of the event relative to the tracked element.
|
|
|
|
* @property {Boolean} shift - True if the shift key was pressed during this event.
|
|
|
|
* @property {Object} originalEvent - The original DOM event.
|
2017-08-21 23:38:44 +03:00
|
|
|
* @property {Boolean} preventDefaultAction - Set to true to prevent default double tap to zoom behaviour. Default: false.
|
2014-04-22 20:23:56 +04:00
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
2017-08-21 23:38:44 +03:00
|
|
|
this.raiseEvent( 'canvas-double-click', canvasDblClickEventArgs);
|
|
|
|
|
|
|
|
if ( !canvasDblClickEventArgs.preventDefaultAction && this.viewport ) {
|
|
|
|
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
|
|
|
|
if ( gestureSettings.dblClickToZoom ) {
|
|
|
|
this.viewport.zoomBy(
|
|
|
|
event.shift ? 1.0 / this.zoomPerClick : this.zoomPerClick,
|
2018-03-16 13:29:16 +03:00
|
|
|
gestureSettings.zoomToRefPoint ? this.viewport.pointFromPixel( event.position, true ) : null
|
2017-08-21 23:38:44 +03:00
|
|
|
);
|
|
|
|
this.viewport.applyConstraints();
|
|
|
|
}
|
|
|
|
}
|
2014-04-22 20:23:56 +04:00
|
|
|
}
|
|
|
|
|
2013-10-11 04:00:15 +04:00
|
|
|
function onCanvasDrag( event ) {
|
2014-04-03 19:50:25 +04:00
|
|
|
var gestureSettings;
|
|
|
|
|
2017-03-15 11:51:44 +03:00
|
|
|
var canvasDragEventArgs = {
|
|
|
|
tracker: event.eventSource,
|
|
|
|
position: event.position,
|
|
|
|
delta: event.delta,
|
|
|
|
speed: event.speed,
|
|
|
|
direction: event.direction,
|
|
|
|
shift: event.shift,
|
|
|
|
originalEvent: event.originalEvent,
|
|
|
|
preventDefaultAction: event.preventDefaultAction
|
|
|
|
};
|
2017-08-03 20:47:35 +03:00
|
|
|
|
2013-11-16 10:19:53 +04:00
|
|
|
/**
|
2013-11-25 20:48:44 +04:00
|
|
|
* Raised when a mouse or touch drag operation occurs on the {@link OpenSeadragon.Viewer#canvas} element.
|
2013-11-22 00:19:07 +04:00
|
|
|
*
|
2013-11-16 10:19:53 +04:00
|
|
|
* @event canvas-drag
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
|
|
|
* @property {OpenSeadragon.MouseTracker} tracker - A reference to the MouseTracker which originated this event.
|
|
|
|
* @property {OpenSeadragon.Point} position - The position of the event relative to the tracked element.
|
|
|
|
* @property {OpenSeadragon.Point} delta - The x,y components of the difference between start drag and end drag.
|
2014-03-30 04:02:24 +04:00
|
|
|
* @property {Number} speed - Current computed speed, in pixels per second.
|
|
|
|
* @property {Number} direction - Current computed direction, expressed as an angle counterclockwise relative to the positive X axis (-pi to pi, in radians). Only valid if speed > 0.
|
2013-11-16 10:19:53 +04:00
|
|
|
* @property {Boolean} shift - True if the shift key was pressed during this event.
|
|
|
|
* @property {Object} originalEvent - The original DOM event.
|
2017-03-15 11:51:44 +03:00
|
|
|
* @property {Boolean} preventDefaultAction - Set to true to prevent default drag behaviour. Default: false.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
2013-11-16 10:19:53 +04:00
|
|
|
*/
|
2017-03-15 11:51:44 +03:00
|
|
|
this.raiseEvent( 'canvas-drag', canvasDragEventArgs);
|
2017-07-11 00:01:04 +03:00
|
|
|
|
2017-08-03 20:47:35 +03:00
|
|
|
if ( !canvasDragEventArgs.preventDefaultAction && this.viewport ) {
|
2014-04-03 19:50:25 +04:00
|
|
|
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
|
2012-04-03 11:08:27 +04:00
|
|
|
if( !this.panHorizontal ){
|
2013-10-11 04:00:15 +04:00
|
|
|
event.delta.x = 0;
|
2012-04-03 11:08:27 +04:00
|
|
|
}
|
|
|
|
if( !this.panVertical ){
|
2013-10-11 04:00:15 +04:00
|
|
|
event.delta.y = 0;
|
2012-04-03 11:08:27 +04:00
|
|
|
}
|
2018-04-10 13:51:06 +03:00
|
|
|
if(this.viewport.flipped){
|
2018-04-04 13:31:18 +03:00
|
|
|
event.delta.x = -event.delta.x;
|
|
|
|
}
|
2017-02-19 19:36:53 +03:00
|
|
|
|
2014-05-06 22:39:02 +04:00
|
|
|
if( this.constrainDuringPan ){
|
2017-02-19 19:36:53 +03:00
|
|
|
var delta = this.viewport.deltaPointsFromPixels( event.delta.negate() );
|
|
|
|
|
2017-02-20 22:23:25 +03:00
|
|
|
this.viewport.centerSpringX.target.value += delta.x;
|
|
|
|
this.viewport.centerSpringY.target.value += delta.y;
|
2017-02-19 19:36:53 +03:00
|
|
|
|
|
|
|
var bounds = this.viewport.getBounds();
|
|
|
|
var constrainedBounds = this.viewport.getConstrainedBounds();
|
|
|
|
|
2017-02-20 22:23:25 +03:00
|
|
|
this.viewport.centerSpringX.target.value -= delta.x;
|
|
|
|
this.viewport.centerSpringY.target.value -= delta.y;
|
2017-02-19 19:36:53 +03:00
|
|
|
|
|
|
|
if (bounds.x != constrainedBounds.x) {
|
|
|
|
event.delta.x = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bounds.y != constrainedBounds.y) {
|
|
|
|
event.delta.y = 0;
|
|
|
|
}
|
2013-02-13 07:40:08 +04:00
|
|
|
}
|
2017-02-19 19:36:53 +03:00
|
|
|
|
2017-07-11 12:58:52 +03:00
|
|
|
this.viewport.panBy( this.viewport.deltaPointsFromPixels( event.delta.negate() ), gestureSettings.flickEnabled && !this.constrainDuringPan);
|
2011-12-08 06:10:13 +04:00
|
|
|
}
|
2014-03-30 04:02:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function onCanvasDragEnd( event ) {
|
2016-03-20 18:01:26 +03:00
|
|
|
if (!event.preventDefaultAction && this.viewport) {
|
|
|
|
var gestureSettings = this.gestureSettingsByDeviceType(event.pointerType);
|
2016-03-20 17:04:23 +03:00
|
|
|
if (gestureSettings.flickEnabled &&
|
|
|
|
event.speed >= gestureSettings.flickMinSpeed) {
|
2016-03-20 18:01:26 +03:00
|
|
|
var amplitudeX = 0;
|
|
|
|
if (this.panHorizontal) {
|
|
|
|
amplitudeX = gestureSettings.flickMomentum * event.speed *
|
|
|
|
Math.cos(event.direction);
|
2014-05-06 22:39:02 +04:00
|
|
|
}
|
2016-03-20 18:01:26 +03:00
|
|
|
var amplitudeY = 0;
|
|
|
|
if (this.panVertical) {
|
|
|
|
amplitudeY = gestureSettings.flickMomentum * event.speed *
|
|
|
|
Math.sin(event.direction);
|
2014-05-06 22:39:02 +04:00
|
|
|
}
|
2016-03-20 17:04:23 +03:00
|
|
|
var center = this.viewport.pixelFromPoint(
|
|
|
|
this.viewport.getCenter(true));
|
|
|
|
var target = this.viewport.pointFromPixel(
|
|
|
|
new $.Point(center.x - amplitudeX, center.y - amplitudeY));
|
2016-03-20 18:01:26 +03:00
|
|
|
this.viewport.panTo(target, false);
|
2014-04-03 19:50:25 +04:00
|
|
|
}
|
2014-08-06 22:26:18 +04:00
|
|
|
this.viewport.applyConstraints();
|
2014-03-30 04:02:24 +04:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Raised when a mouse or touch drag operation ends on the {@link OpenSeadragon.Viewer#canvas} element.
|
|
|
|
*
|
|
|
|
* @event canvas-drag-end
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
|
|
|
* @property {OpenSeadragon.MouseTracker} tracker - A reference to the MouseTracker which originated this event.
|
|
|
|
* @property {OpenSeadragon.Point} position - The position of the event relative to the tracked element.
|
|
|
|
* @property {Number} speed - Speed at the end of a drag gesture, in pixels per second.
|
|
|
|
* @property {Number} direction - Direction at the end of a drag gesture, expressed as an angle counterclockwise relative to the positive X axis (-pi to pi, in radians). Only valid if speed > 0.
|
|
|
|
* @property {Boolean} shift - True if the shift key was pressed during this event.
|
|
|
|
* @property {Object} originalEvent - The original DOM event.
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
2016-03-20 18:01:26 +03:00
|
|
|
this.raiseEvent('canvas-drag-end', {
|
2014-03-30 04:02:24 +04:00
|
|
|
tracker: event.eventSource,
|
|
|
|
position: event.position,
|
|
|
|
speed: event.speed,
|
|
|
|
direction: event.direction,
|
2013-10-15 22:11:08 +04:00
|
|
|
shift: event.shift,
|
|
|
|
originalEvent: event.originalEvent
|
2013-02-14 04:44:23 +04:00
|
|
|
});
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-08 06:10:13 +04:00
|
|
|
|
2015-01-15 23:15:22 +03:00
|
|
|
function onCanvasEnter( event ) {
|
|
|
|
/**
|
|
|
|
* Raised when a pointer enters the {@link OpenSeadragon.Viewer#canvas} element.
|
|
|
|
*
|
|
|
|
* @event canvas-enter
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
|
|
|
* @property {OpenSeadragon.MouseTracker} tracker - A reference to the MouseTracker which originated this event.
|
|
|
|
* @property {String} pointerType - "mouse", "touch", "pen", etc.
|
|
|
|
* @property {OpenSeadragon.Point} position - The position of the event relative to the tracked element.
|
|
|
|
* @property {Number} buttons - Current buttons pressed. A combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
|
|
|
* @property {Number} pointers - Number of pointers (all types) active in the tracked element.
|
|
|
|
* @property {Boolean} insideElementPressed - True if the left mouse button is currently being pressed and was initiated inside the tracked element, otherwise false.
|
|
|
|
* @property {Boolean} buttonDownAny - Was the button down anywhere in the screen during the event. <span style="color:red;">Deprecated. Use buttons instead.</span>
|
|
|
|
* @property {Object} originalEvent - The original DOM event.
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
|
|
|
this.raiseEvent( 'canvas-enter', {
|
|
|
|
tracker: event.eventSource,
|
|
|
|
pointerType: event.pointerType,
|
|
|
|
position: event.position,
|
|
|
|
buttons: event.buttons,
|
|
|
|
pointers: event.pointers,
|
|
|
|
insideElementPressed: event.insideElementPressed,
|
|
|
|
buttonDownAny: event.buttonDownAny,
|
|
|
|
originalEvent: event.originalEvent
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function onCanvasExit( event ) {
|
2017-02-19 19:36:53 +03:00
|
|
|
|
2017-02-23 21:15:29 +03:00
|
|
|
if (window.location != window.parent.location){
|
|
|
|
$.MouseTracker.resetAllMouseTrackers();
|
|
|
|
}
|
|
|
|
|
2015-01-15 23:15:22 +03:00
|
|
|
/**
|
|
|
|
* Raised when a pointer leaves the {@link OpenSeadragon.Viewer#canvas} element.
|
|
|
|
*
|
|
|
|
* @event canvas-exit
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
|
|
|
* @property {OpenSeadragon.MouseTracker} tracker - A reference to the MouseTracker which originated this event.
|
|
|
|
* @property {String} pointerType - "mouse", "touch", "pen", etc.
|
|
|
|
* @property {OpenSeadragon.Point} position - The position of the event relative to the tracked element.
|
|
|
|
* @property {Number} buttons - Current buttons pressed. A combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
|
|
|
* @property {Number} pointers - Number of pointers (all types) active in the tracked element.
|
|
|
|
* @property {Boolean} insideElementPressed - True if the left mouse button is currently being pressed and was initiated inside the tracked element, otherwise false.
|
|
|
|
* @property {Boolean} buttonDownAny - Was the button down anywhere in the screen during the event. <span style="color:red;">Deprecated. Use buttons instead.</span>
|
|
|
|
* @property {Object} originalEvent - The original DOM event.
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
|
|
|
this.raiseEvent( 'canvas-exit', {
|
|
|
|
tracker: event.eventSource,
|
|
|
|
pointerType: event.pointerType,
|
|
|
|
position: event.position,
|
|
|
|
buttons: event.buttons,
|
|
|
|
pointers: event.pointers,
|
|
|
|
insideElementPressed: event.insideElementPressed,
|
|
|
|
buttonDownAny: event.buttonDownAny,
|
|
|
|
originalEvent: event.originalEvent
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function onCanvasPress( event ) {
|
|
|
|
/**
|
|
|
|
* Raised when the primary mouse button is pressed or touch starts on the {@link OpenSeadragon.Viewer#canvas} element.
|
|
|
|
*
|
|
|
|
* @event canvas-press
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
|
|
|
* @property {OpenSeadragon.MouseTracker} tracker - A reference to the MouseTracker which originated this event.
|
|
|
|
* @property {String} pointerType - "mouse", "touch", "pen", etc.
|
|
|
|
* @property {OpenSeadragon.Point} position - The position of the event relative to the tracked element.
|
|
|
|
* @property {Boolean} insideElementPressed - True if the left mouse button is currently being pressed and was initiated inside the tracked element, otherwise false.
|
|
|
|
* @property {Boolean} insideElementReleased - True if the cursor still inside the tracked element when the button was released.
|
|
|
|
* @property {Object} originalEvent - The original DOM event.
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
|
|
|
this.raiseEvent( 'canvas-press', {
|
|
|
|
tracker: event.eventSource,
|
|
|
|
pointerType: event.pointerType,
|
|
|
|
position: event.position,
|
|
|
|
insideElementPressed: event.insideElementPressed,
|
|
|
|
insideElementReleased: event.insideElementReleased,
|
|
|
|
originalEvent: event.originalEvent
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-10-11 04:00:15 +04:00
|
|
|
function onCanvasRelease( event ) {
|
2013-11-16 10:19:53 +04:00
|
|
|
/**
|
2015-01-11 01:49:02 +03:00
|
|
|
* Raised when the primary mouse button is released or touch ends on the {@link OpenSeadragon.Viewer#canvas} element.
|
2013-11-22 00:19:07 +04:00
|
|
|
*
|
2013-11-16 10:19:53 +04:00
|
|
|
* @event canvas-release
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
|
|
|
* @property {OpenSeadragon.MouseTracker} tracker - A reference to the MouseTracker which originated this event.
|
2015-01-15 23:15:22 +03:00
|
|
|
* @property {String} pointerType - "mouse", "touch", "pen", etc.
|
2013-11-16 10:19:53 +04:00
|
|
|
* @property {OpenSeadragon.Point} position - The position of the event relative to the tracked element.
|
|
|
|
* @property {Boolean} insideElementPressed - True if the left mouse button is currently being pressed and was initiated inside the tracked element, otherwise false.
|
|
|
|
* @property {Boolean} insideElementReleased - True if the cursor still inside the tracked element when the button was released.
|
|
|
|
* @property {Object} originalEvent - The original DOM event.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
2013-11-16 10:19:53 +04:00
|
|
|
*/
|
2013-09-30 21:22:06 +04:00
|
|
|
this.raiseEvent( 'canvas-release', {
|
2013-10-11 04:00:15 +04:00
|
|
|
tracker: event.eventSource,
|
2015-01-15 23:15:22 +03:00
|
|
|
pointerType: event.pointerType,
|
2013-10-11 04:00:15 +04:00
|
|
|
position: event.position,
|
|
|
|
insideElementPressed: event.insideElementPressed,
|
2013-10-15 22:11:08 +04:00
|
|
|
insideElementReleased: event.insideElementReleased,
|
|
|
|
originalEvent: event.originalEvent
|
2013-02-14 04:44:23 +04:00
|
|
|
});
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-08 06:10:13 +04:00
|
|
|
|
2015-01-12 22:02:54 +03:00
|
|
|
function onCanvasNonPrimaryPress( event ) {
|
2015-01-11 01:49:02 +03:00
|
|
|
/**
|
|
|
|
* Raised when any non-primary pointer button is pressed on the {@link OpenSeadragon.Viewer#canvas} element.
|
|
|
|
*
|
2015-01-12 22:02:54 +03:00
|
|
|
* @event canvas-nonprimary-press
|
2015-01-11 01:49:02 +03:00
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
|
|
|
* @property {OpenSeadragon.MouseTracker} tracker - A reference to the MouseTracker which originated this event.
|
|
|
|
* @property {OpenSeadragon.Point} position - The position of the event relative to the tracked element.
|
|
|
|
* @property {String} pointerType - "mouse", "touch", "pen", etc.
|
|
|
|
* @property {Number} button - Button which caused the event.
|
|
|
|
* -1: none, 0: primary/left, 1: aux/middle, 2: secondary/right, 3: X1/back, 4: X2/forward, 5: pen eraser.
|
|
|
|
* @property {Number} buttons - Current buttons pressed.
|
|
|
|
* Combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
|
|
|
* @property {Object} originalEvent - The original DOM event.
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
2015-01-12 22:02:54 +03:00
|
|
|
this.raiseEvent( 'canvas-nonprimary-press', {
|
2015-01-11 01:49:02 +03:00
|
|
|
tracker: event.eventSource,
|
|
|
|
position: event.position,
|
|
|
|
pointerType: event.pointerType,
|
|
|
|
button: event.button,
|
|
|
|
buttons: event.buttons,
|
|
|
|
originalEvent: event.originalEvent
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-01-12 22:02:54 +03:00
|
|
|
function onCanvasNonPrimaryRelease( event ) {
|
2015-01-11 01:49:02 +03:00
|
|
|
/**
|
|
|
|
* Raised when any non-primary pointer button is released on the {@link OpenSeadragon.Viewer#canvas} element.
|
|
|
|
*
|
2015-01-12 22:02:54 +03:00
|
|
|
* @event canvas-nonprimary-release
|
2015-01-11 01:49:02 +03:00
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
|
|
|
* @property {OpenSeadragon.MouseTracker} tracker - A reference to the MouseTracker which originated this event.
|
|
|
|
* @property {OpenSeadragon.Point} position - The position of the event relative to the tracked element.
|
|
|
|
* @property {String} pointerType - "mouse", "touch", "pen", etc.
|
|
|
|
* @property {Number} button - Button which caused the event.
|
|
|
|
* -1: none, 0: primary/left, 1: aux/middle, 2: secondary/right, 3: X1/back, 4: X2/forward, 5: pen eraser.
|
|
|
|
* @property {Number} buttons - Current buttons pressed.
|
|
|
|
* Combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
|
|
|
* @property {Object} originalEvent - The original DOM event.
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
2015-01-12 22:02:54 +03:00
|
|
|
this.raiseEvent( 'canvas-nonprimary-release', {
|
2015-01-11 01:49:02 +03:00
|
|
|
tracker: event.eventSource,
|
|
|
|
position: event.position,
|
|
|
|
pointerType: event.pointerType,
|
|
|
|
button: event.button,
|
|
|
|
buttons: event.buttons,
|
|
|
|
originalEvent: event.originalEvent
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-03-30 04:02:24 +04:00
|
|
|
function onCanvasPinch( event ) {
|
2014-05-06 22:39:02 +04:00
|
|
|
var gestureSettings,
|
|
|
|
centerPt,
|
|
|
|
lastCenterPt,
|
|
|
|
panByPt;
|
2014-04-16 06:19:47 +04:00
|
|
|
|
2013-11-05 00:41:45 +04:00
|
|
|
if ( !event.preventDefaultAction && this.viewport ) {
|
2014-04-16 06:19:47 +04:00
|
|
|
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
|
|
|
|
if ( gestureSettings.pinchToZoom ) {
|
2014-05-06 22:39:02 +04:00
|
|
|
centerPt = this.viewport.pointFromPixel( event.center, true );
|
|
|
|
lastCenterPt = this.viewport.pointFromPixel( event.lastCenter, true );
|
|
|
|
panByPt = lastCenterPt.minus( centerPt );
|
|
|
|
if( !this.panHorizontal ) {
|
|
|
|
panByPt.x = 0;
|
|
|
|
}
|
|
|
|
if( !this.panVertical ) {
|
|
|
|
panByPt.y = 0;
|
|
|
|
}
|
2014-04-16 06:19:47 +04:00
|
|
|
this.viewport.zoomBy( event.distance / event.lastDistance, centerPt, true );
|
2018-03-16 13:29:16 +03:00
|
|
|
if ( gestureSettings.zoomToRefPoint ) {
|
|
|
|
this.viewport.panBy(panByPt, true);
|
|
|
|
}
|
2014-04-16 06:19:47 +04:00
|
|
|
this.viewport.applyConstraints();
|
|
|
|
}
|
2014-08-22 18:22:00 +04:00
|
|
|
if ( gestureSettings.pinchRotate ) {
|
|
|
|
// Pinch rotate
|
|
|
|
var angle1 = Math.atan2(event.gesturePoints[0].currentPos.y - event.gesturePoints[1].currentPos.y,
|
|
|
|
event.gesturePoints[0].currentPos.x - event.gesturePoints[1].currentPos.x);
|
|
|
|
var angle2 = Math.atan2(event.gesturePoints[0].lastPos.y - event.gesturePoints[1].lastPos.y,
|
|
|
|
event.gesturePoints[0].lastPos.x - event.gesturePoints[1].lastPos.x);
|
|
|
|
this.viewport.setRotation(this.viewport.getRotation() + ((angle1 - angle2) * (180 / Math.PI)));
|
|
|
|
}
|
2011-12-08 06:10:13 +04:00
|
|
|
}
|
2013-11-16 10:19:53 +04:00
|
|
|
/**
|
2014-03-30 04:02:24 +04:00
|
|
|
* Raised when a pinch event occurs on the {@link OpenSeadragon.Viewer#canvas} element.
|
2013-11-22 00:19:07 +04:00
|
|
|
*
|
2014-03-30 04:02:24 +04:00
|
|
|
* @event canvas-pinch
|
2013-11-16 10:19:53 +04:00
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
|
|
|
* @property {OpenSeadragon.MouseTracker} tracker - A reference to the MouseTracker which originated this event.
|
2014-03-30 04:02:24 +04:00
|
|
|
* @property {Array.<OpenSeadragon.MouseTracker.GesturePoint>} gesturePoints - Gesture points associated with the gesture. Velocity data can be found here.
|
|
|
|
* @property {OpenSeadragon.Point} lastCenter - The previous center point of the two pinch contact points relative to the tracked element.
|
|
|
|
* @property {OpenSeadragon.Point} center - The center point of the two pinch contact points relative to the tracked element.
|
|
|
|
* @property {Number} lastDistance - The previous distance between the two pinch contact points in CSS pixels.
|
|
|
|
* @property {Number} distance - The distance between the two pinch contact points in CSS pixels.
|
2013-11-16 10:19:53 +04:00
|
|
|
* @property {Boolean} shift - True if the shift key was pressed during this event.
|
|
|
|
* @property {Object} originalEvent - The original DOM event.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
2013-11-16 10:19:53 +04:00
|
|
|
*/
|
2014-03-30 04:02:24 +04:00
|
|
|
this.raiseEvent('canvas-pinch', {
|
2013-10-11 04:00:15 +04:00
|
|
|
tracker: event.eventSource,
|
2014-03-30 04:02:24 +04:00
|
|
|
gesturePoints: event.gesturePoints,
|
|
|
|
lastCenter: event.lastCenter,
|
|
|
|
center: event.center,
|
|
|
|
lastDistance: event.lastDistance,
|
|
|
|
distance: event.distance,
|
2013-10-15 22:11:08 +04:00
|
|
|
shift: event.shift,
|
|
|
|
originalEvent: event.originalEvent
|
2013-02-14 04:44:23 +04:00
|
|
|
});
|
2012-04-03 11:08:27 +04:00
|
|
|
//cancels event
|
|
|
|
return false;
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-08 06:10:13 +04:00
|
|
|
|
2014-03-30 04:02:24 +04:00
|
|
|
function onCanvasScroll( event ) {
|
2014-04-03 21:06:12 +04:00
|
|
|
var gestureSettings,
|
2015-10-27 23:00:45 +03:00
|
|
|
factor,
|
2015-10-29 02:07:51 +03:00
|
|
|
thisScrollTime,
|
|
|
|
deltaScrollTime;
|
2015-10-27 23:00:45 +03:00
|
|
|
|
|
|
|
/* Certain scroll devices fire the scroll event way too fast so we are injecting a simple adjustment to keep things
|
|
|
|
* partially normalized. If we have already fired an event within the last 'minScrollDelta' milliseconds we skip
|
|
|
|
* this one and wait for the next event. */
|
2015-10-29 02:07:51 +03:00
|
|
|
thisScrollTime = $.now();
|
|
|
|
deltaScrollTime = thisScrollTime - this._lastScrollTime;
|
|
|
|
if (deltaScrollTime > this.minScrollDeltaTime) {
|
|
|
|
this._lastScrollTime = thisScrollTime;
|
2015-10-27 23:00:45 +03:00
|
|
|
|
2018-04-10 13:51:06 +03:00
|
|
|
if(this.viewport.flipped){
|
2018-04-04 13:31:18 +03:00
|
|
|
event.position.x = this.viewport.getContainerSize().x - event.position.x;
|
|
|
|
}
|
|
|
|
|
2015-10-27 23:00:45 +03:00
|
|
|
if ( !event.preventDefaultAction && this.viewport ) {
|
|
|
|
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
|
|
|
|
if ( gestureSettings.scrollToZoom ) {
|
|
|
|
factor = Math.pow( this.zoomPerScroll, event.scroll );
|
|
|
|
this.viewport.zoomBy(
|
|
|
|
factor,
|
2018-03-16 13:29:16 +03:00
|
|
|
gestureSettings.zoomToRefPoint ? this.viewport.pointFromPixel( event.position, true ) : null
|
2015-10-27 23:00:45 +03:00
|
|
|
);
|
|
|
|
this.viewport.applyConstraints();
|
|
|
|
}
|
2014-04-03 21:06:12 +04:00
|
|
|
}
|
2015-10-27 23:00:45 +03:00
|
|
|
/**
|
|
|
|
* Raised when a scroll event occurs on the {@link OpenSeadragon.Viewer#canvas} element (mouse wheel).
|
|
|
|
*
|
|
|
|
* @event canvas-scroll
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
|
|
|
* @property {OpenSeadragon.MouseTracker} tracker - A reference to the MouseTracker which originated this event.
|
|
|
|
* @property {OpenSeadragon.Point} position - The position of the event relative to the tracked element.
|
|
|
|
* @property {Number} scroll - The scroll delta for the event.
|
|
|
|
* @property {Boolean} shift - True if the shift key was pressed during this event.
|
|
|
|
* @property {Object} originalEvent - The original DOM event.
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
|
|
|
this.raiseEvent( 'canvas-scroll', {
|
|
|
|
tracker: event.eventSource,
|
|
|
|
position: event.position,
|
|
|
|
scroll: event.scroll,
|
|
|
|
shift: event.shift,
|
|
|
|
originalEvent: event.originalEvent
|
|
|
|
});
|
2015-11-03 02:03:27 +03:00
|
|
|
if (gestureSettings && gestureSettings.scrollToZoom) {
|
|
|
|
//cancels event
|
|
|
|
return false;
|
2014-04-03 21:06:12 +04:00
|
|
|
}
|
2014-03-10 22:49:51 +04:00
|
|
|
}
|
2015-11-03 02:03:27 +03:00
|
|
|
else {
|
2016-02-22 21:59:37 +03:00
|
|
|
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
|
|
|
|
if (gestureSettings && gestureSettings.scrollToZoom) {
|
|
|
|
return false; // We are swallowing this event
|
|
|
|
}
|
2015-01-09 22:45:53 +03:00
|
|
|
}
|
2014-03-10 22:49:51 +04:00
|
|
|
}
|
|
|
|
|
2015-01-15 23:15:22 +03:00
|
|
|
function onContainerEnter( event ) {
|
|
|
|
THIS[ this.hash ].mouseInside = true;
|
|
|
|
abortControlsAutoHide( this );
|
2013-11-16 10:19:53 +04:00
|
|
|
/**
|
2015-01-15 23:15:22 +03:00
|
|
|
* Raised when the cursor enters the {@link OpenSeadragon.Viewer#container} element.
|
2013-11-22 00:19:07 +04:00
|
|
|
*
|
2015-01-15 23:15:22 +03:00
|
|
|
* @event container-enter
|
2013-11-16 10:19:53 +04:00
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
|
|
|
* @property {OpenSeadragon.MouseTracker} tracker - A reference to the MouseTracker which originated this event.
|
|
|
|
* @property {OpenSeadragon.Point} position - The position of the event relative to the tracked element.
|
2014-04-15 05:17:18 +04:00
|
|
|
* @property {Number} buttons - Current buttons pressed. A combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
2015-01-15 23:37:54 +03:00
|
|
|
* @property {Number} pointers - Number of pointers (all types) active in the tracked element.
|
2013-11-16 10:19:53 +04:00
|
|
|
* @property {Boolean} insideElementPressed - True if the left mouse button is currently being pressed and was initiated inside the tracked element, otherwise false.
|
2014-04-15 05:17:18 +04:00
|
|
|
* @property {Boolean} buttonDownAny - Was the button down anywhere in the screen during the event. <span style="color:red;">Deprecated. Use buttons instead.</span>
|
2013-11-16 10:19:53 +04:00
|
|
|
* @property {Object} originalEvent - The original DOM event.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
2013-11-16 10:19:53 +04:00
|
|
|
*/
|
2015-01-15 23:15:22 +03:00
|
|
|
this.raiseEvent( 'container-enter', {
|
2013-10-11 04:00:15 +04:00
|
|
|
tracker: event.eventSource,
|
|
|
|
position: event.position,
|
2014-04-15 05:17:18 +04:00
|
|
|
buttons: event.buttons,
|
2015-01-15 23:37:54 +03:00
|
|
|
pointers: event.pointers,
|
2013-10-11 04:00:15 +04:00
|
|
|
insideElementPressed: event.insideElementPressed,
|
2013-10-15 22:11:08 +04:00
|
|
|
buttonDownAny: event.buttonDownAny,
|
|
|
|
originalEvent: event.originalEvent
|
2013-02-14 04:44:23 +04:00
|
|
|
});
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-08 06:10:13 +04:00
|
|
|
|
2015-01-15 23:15:22 +03:00
|
|
|
function onContainerExit( event ) {
|
|
|
|
if ( event.pointers < 1 ) {
|
2012-02-27 15:56:29 +04:00
|
|
|
THIS[ this.hash ].mouseInside = false;
|
|
|
|
if ( !THIS[ this.hash ].animating ) {
|
2011-12-08 06:10:13 +04:00
|
|
|
beginControlsAutoHide( this );
|
|
|
|
}
|
|
|
|
}
|
2013-11-16 10:19:53 +04:00
|
|
|
/**
|
2015-01-15 23:15:22 +03:00
|
|
|
* Raised when the cursor leaves the {@link OpenSeadragon.Viewer#container} element.
|
2013-11-22 00:19:07 +04:00
|
|
|
*
|
2015-01-15 23:15:22 +03:00
|
|
|
* @event container-exit
|
2013-11-16 10:19:53 +04:00
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
|
|
|
* @property {OpenSeadragon.MouseTracker} tracker - A reference to the MouseTracker which originated this event.
|
|
|
|
* @property {OpenSeadragon.Point} position - The position of the event relative to the tracked element.
|
2014-04-15 05:17:18 +04:00
|
|
|
* @property {Number} buttons - Current buttons pressed. A combination of bit flags 0: none, 1: primary (or touch contact), 2: secondary, 4: aux (often middle), 8: X1 (often back), 16: X2 (often forward), 32: pen eraser.
|
2015-01-15 23:37:54 +03:00
|
|
|
* @property {Number} pointers - Number of pointers (all types) active in the tracked element.
|
2013-11-16 10:19:53 +04:00
|
|
|
* @property {Boolean} insideElementPressed - True if the left mouse button is currently being pressed and was initiated inside the tracked element, otherwise false.
|
2014-04-15 05:17:18 +04:00
|
|
|
* @property {Boolean} buttonDownAny - Was the button down anywhere in the screen during the event. <span style="color:red;">Deprecated. Use buttons instead.</span>
|
2013-11-16 10:19:53 +04:00
|
|
|
* @property {Object} originalEvent - The original DOM event.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
2013-11-16 10:19:53 +04:00
|
|
|
*/
|
2015-01-15 23:15:22 +03:00
|
|
|
this.raiseEvent( 'container-exit', {
|
2013-10-11 04:00:15 +04:00
|
|
|
tracker: event.eventSource,
|
|
|
|
position: event.position,
|
2014-04-15 05:17:18 +04:00
|
|
|
buttons: event.buttons,
|
2015-01-15 23:37:54 +03:00
|
|
|
pointers: event.pointers,
|
2013-10-11 04:00:15 +04:00
|
|
|
insideElementPressed: event.insideElementPressed,
|
2013-10-15 22:11:08 +04:00
|
|
|
buttonDownAny: event.buttonDownAny,
|
|
|
|
originalEvent: event.originalEvent
|
2013-02-14 04:44:23 +04:00
|
|
|
});
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-08 06:10:13 +04:00
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Page update routines ( aka Views - for future reference )
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2011-12-23 05:47:21 +04:00
|
|
|
|
2013-04-27 05:48:48 +04:00
|
|
|
function updateMulti( viewer ) {
|
2011-12-23 05:47:21 +04:00
|
|
|
updateOnce( viewer );
|
2013-04-27 06:32:51 +04:00
|
|
|
|
2014-10-30 02:11:21 +03:00
|
|
|
// Request the next frame, unless we've been closed
|
|
|
|
if ( viewer.isOpen() ) {
|
2013-06-19 20:58:09 +04:00
|
|
|
viewer._updateRequestId = scheduleUpdate( viewer, updateMulti );
|
2014-10-30 02:11:21 +03:00
|
|
|
} else {
|
|
|
|
viewer._updateRequestId = false;
|
2013-06-17 22:30:31 +04:00
|
|
|
}
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-23 05:47:21 +04:00
|
|
|
|
2011-12-23 05:36:17 +04:00
|
|
|
function updateOnce( viewer ) {
|
2012-01-24 17:03:50 +04:00
|
|
|
|
2011-12-30 02:14:42 +04:00
|
|
|
//viewer.profiler.beginUpdate();
|
2011-12-23 05:36:17 +04:00
|
|
|
|
2015-02-10 22:30:36 +03:00
|
|
|
if (viewer._opening) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-05-13 02:23:09 +03:00
|
|
|
if (viewer.autoResize) {
|
|
|
|
var containerSize = _getSafeElemSize(viewer.container);
|
|
|
|
var prevContainerSize = THIS[viewer.hash].prevContainerSize;
|
|
|
|
if (!containerSize.equals(prevContainerSize)) {
|
|
|
|
var viewport = viewer.viewport;
|
|
|
|
if (viewer.preserveImageSizeOnResize) {
|
|
|
|
var resizeRatio = prevContainerSize.x / containerSize.x;
|
|
|
|
var zoom = viewport.getZoom() * resizeRatio;
|
|
|
|
var center = viewport.getCenter();
|
|
|
|
viewport.resize(containerSize, false);
|
|
|
|
viewport.zoomTo(zoom, null, true);
|
|
|
|
viewport.panTo(center, true);
|
|
|
|
} else {
|
2015-06-24 19:48:00 +03:00
|
|
|
// maintain image position
|
2016-05-13 02:23:09 +03:00
|
|
|
var oldBounds = viewport.getBounds();
|
|
|
|
viewport.resize(containerSize, true);
|
|
|
|
viewport.fitBoundsWithConstraints(oldBounds, true);
|
2015-06-24 19:48:00 +03:00
|
|
|
}
|
2016-05-13 02:23:09 +03:00
|
|
|
THIS[viewer.hash].prevContainerSize = containerSize;
|
|
|
|
THIS[viewer.hash].forceRedraw = true;
|
2015-06-22 22:26:24 +03:00
|
|
|
}
|
|
|
|
}
|
2011-12-23 05:36:17 +04:00
|
|
|
|
2015-01-20 22:23:34 +03:00
|
|
|
var viewportChange = viewer.viewport.update();
|
|
|
|
var animated = viewer.world.update() || viewportChange;
|
|
|
|
|
|
|
|
if (viewportChange) {
|
|
|
|
/**
|
|
|
|
* Raised when any spring animation update occurs (zoom, pan, etc.),
|
|
|
|
* before the viewer has drawn the new location.
|
|
|
|
*
|
|
|
|
* @event viewport-change
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
|
|
|
viewer.raiseEvent('viewport-change');
|
|
|
|
}
|
2012-09-05 18:52:57 +04:00
|
|
|
|
|
|
|
if( viewer.referenceStrip ){
|
|
|
|
animated = viewer.referenceStrip.update( viewer.viewport ) || animated;
|
|
|
|
}
|
2012-10-13 07:40:59 +04:00
|
|
|
|
2012-02-27 15:56:29 +04:00
|
|
|
if ( !THIS[ viewer.hash ].animating && animated ) {
|
2013-11-16 10:19:53 +04:00
|
|
|
/**
|
2013-11-22 00:19:07 +04:00
|
|
|
* Raised when any spring animation starts (zoom, pan, etc.).
|
|
|
|
*
|
2013-11-16 10:19:53 +04:00
|
|
|
* @event animation-start
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
2013-11-16 10:19:53 +04:00
|
|
|
*/
|
2013-09-30 21:22:06 +04:00
|
|
|
viewer.raiseEvent( "animation-start" );
|
2011-12-23 05:36:17 +04:00
|
|
|
abortControlsAutoHide( viewer );
|
|
|
|
}
|
2011-12-08 06:10:13 +04:00
|
|
|
|
2014-12-02 22:44:02 +03:00
|
|
|
if ( animated || THIS[ viewer.hash ].forceRedraw || viewer.world.needsDraw() ) {
|
|
|
|
drawWorld( viewer );
|
2014-11-21 02:33:13 +03:00
|
|
|
viewer._drawOverlays();
|
2012-03-07 07:20:00 +04:00
|
|
|
if( viewer.navigator ){
|
2018-04-04 13:31:18 +03:00
|
|
|
viewer.navigator.update( viewer.viewport );
|
2012-03-07 07:20:00 +04:00
|
|
|
}
|
2014-10-30 02:11:21 +03:00
|
|
|
|
2012-02-27 15:56:29 +04:00
|
|
|
THIS[ viewer.hash ].forceRedraw = false;
|
2014-10-30 02:11:21 +03:00
|
|
|
|
|
|
|
if (animated) {
|
|
|
|
/**
|
2015-01-20 22:23:34 +03:00
|
|
|
* Raised when any spring animation update occurs (zoom, pan, etc.),
|
|
|
|
* after the viewer has drawn the new location.
|
2014-10-30 02:11:21 +03:00
|
|
|
*
|
|
|
|
* @event animation
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
|
|
|
viewer.raiseEvent( "animation" );
|
|
|
|
}
|
2013-06-19 21:33:25 +04:00
|
|
|
}
|
2011-12-23 05:36:17 +04:00
|
|
|
|
2012-02-27 15:56:29 +04:00
|
|
|
if ( THIS[ viewer.hash ].animating && !animated ) {
|
2013-11-16 10:19:53 +04:00
|
|
|
/**
|
2013-11-22 00:19:07 +04:00
|
|
|
* Raised when any spring animation ends (zoom, pan, etc.).
|
|
|
|
*
|
2013-11-16 10:19:53 +04:00
|
|
|
* @event animation-finish
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
2013-11-18 18:56:32 +04:00
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
2013-11-16 10:19:53 +04:00
|
|
|
*/
|
2013-09-30 21:22:06 +04:00
|
|
|
viewer.raiseEvent( "animation-finish" );
|
2011-12-23 05:36:17 +04:00
|
|
|
|
2012-02-27 15:56:29 +04:00
|
|
|
if ( !THIS[ viewer.hash ].mouseInside ) {
|
2011-12-23 05:36:17 +04:00
|
|
|
beginControlsAutoHide( viewer );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-27 15:56:29 +04:00
|
|
|
THIS[ viewer.hash ].animating = animated;
|
2011-12-23 05:36:17 +04:00
|
|
|
|
2011-12-30 02:14:42 +04:00
|
|
|
//viewer.profiler.endUpdate();
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-13 07:40:02 +04:00
|
|
|
|
2014-12-02 22:44:02 +03:00
|
|
|
function drawWorld( viewer ) {
|
2015-03-03 11:29:44 +03:00
|
|
|
viewer.imageLoader.clear();
|
2014-08-07 00:48:18 +04:00
|
|
|
viewer.drawer.clear();
|
2014-12-02 22:44:02 +03:00
|
|
|
viewer.world.draw();
|
2014-08-20 02:43:36 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* <em>- Needs documentation -</em>
|
|
|
|
*
|
|
|
|
* @event update-viewport
|
|
|
|
* @memberof OpenSeadragon.Viewer
|
|
|
|
* @type {object}
|
|
|
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
|
|
|
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
|
|
|
*/
|
|
|
|
viewer.raiseEvent( 'update-viewport', {} );
|
2013-12-01 02:28:17 +04:00
|
|
|
}
|
|
|
|
|
2011-12-23 05:08:06 +04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Navigation Controls
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
function resolveUrl( prefix, url ) {
|
|
|
|
return prefix ? prefix + url : url;
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-23 05:08:06 +04:00
|
|
|
|
|
|
|
|
2012-04-03 11:08:27 +04:00
|
|
|
|
2011-12-23 05:08:06 +04:00
|
|
|
function beginZoomingIn() {
|
2013-06-21 00:15:04 +04:00
|
|
|
THIS[ this.hash ].lastZoomTime = $.now();
|
2012-03-01 17:38:15 +04:00
|
|
|
THIS[ this.hash ].zoomFactor = this.zoomPerSecond;
|
2012-02-27 15:56:29 +04:00
|
|
|
THIS[ this.hash ].zooming = true;
|
2011-12-23 05:08:06 +04:00
|
|
|
scheduleZoom( this );
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2012-04-03 11:08:27 +04:00
|
|
|
|
2011-12-23 05:08:06 +04:00
|
|
|
|
|
|
|
function beginZoomingOut() {
|
2013-06-21 00:15:04 +04:00
|
|
|
THIS[ this.hash ].lastZoomTime = $.now();
|
2012-03-01 17:38:15 +04:00
|
|
|
THIS[ this.hash ].zoomFactor = 1.0 / this.zoomPerSecond;
|
2012-02-27 15:56:29 +04:00
|
|
|
THIS[ this.hash ].zooming = true;
|
2011-12-23 05:08:06 +04:00
|
|
|
scheduleZoom( this );
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2012-04-03 11:08:27 +04:00
|
|
|
|
2011-12-23 05:08:06 +04:00
|
|
|
|
|
|
|
function endZooming() {
|
2012-02-27 15:56:29 +04:00
|
|
|
THIS[ this.hash ].zooming = false;
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2012-04-03 11:08:27 +04:00
|
|
|
|
2011-12-23 05:08:06 +04:00
|
|
|
|
|
|
|
function scheduleZoom( viewer ) {
|
2013-02-26 19:19:48 +04:00
|
|
|
$.requestAnimationFrame( $.delegate( viewer, doZoom ) );
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2012-04-03 11:08:27 +04:00
|
|
|
|
2011-12-23 05:08:06 +04:00
|
|
|
|
|
|
|
function doZoom() {
|
2012-01-24 17:03:50 +04:00
|
|
|
var currentTime,
|
|
|
|
deltaTime,
|
2013-06-19 01:56:13 +04:00
|
|
|
adjustedFactor;
|
2012-01-24 17:03:50 +04:00
|
|
|
|
2012-02-27 15:56:29 +04:00
|
|
|
if ( THIS[ this.hash ].zooming && this.viewport) {
|
2013-06-21 00:15:04 +04:00
|
|
|
currentTime = $.now();
|
2012-02-27 15:56:29 +04:00
|
|
|
deltaTime = currentTime - THIS[ this.hash ].lastZoomTime;
|
|
|
|
adjustedFactor = Math.pow( THIS[ this.hash ].zoomFactor, deltaTime / 1000 );
|
2011-12-23 05:08:06 +04:00
|
|
|
|
2012-01-24 17:03:50 +04:00
|
|
|
this.viewport.zoomBy( adjustedFactor );
|
2011-12-23 05:08:06 +04:00
|
|
|
this.viewport.applyConstraints();
|
2012-02-27 15:56:29 +04:00
|
|
|
THIS[ this.hash ].lastZoomTime = currentTime;
|
2011-12-23 05:08:06 +04:00
|
|
|
scheduleZoom( this );
|
|
|
|
}
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-23 05:08:06 +04:00
|
|
|
|
2012-04-03 11:08:27 +04:00
|
|
|
|
2011-12-23 05:08:06 +04:00
|
|
|
function doSingleZoomIn() {
|
2012-01-24 17:03:50 +04:00
|
|
|
if ( this.viewport ) {
|
2012-02-27 15:56:29 +04:00
|
|
|
THIS[ this.hash ].zooming = false;
|
2013-06-19 21:33:25 +04:00
|
|
|
this.viewport.zoomBy(
|
|
|
|
this.zoomPerClick / 1.0
|
2011-12-23 05:08:06 +04:00
|
|
|
);
|
|
|
|
this.viewport.applyConstraints();
|
|
|
|
}
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-23 05:08:06 +04:00
|
|
|
|
2012-04-03 11:08:27 +04:00
|
|
|
|
2011-12-23 05:08:06 +04:00
|
|
|
function doSingleZoomOut() {
|
2012-01-24 17:03:50 +04:00
|
|
|
if ( this.viewport ) {
|
2012-02-27 15:56:29 +04:00
|
|
|
THIS[ this.hash ].zooming = false;
|
2011-12-23 05:08:06 +04:00
|
|
|
this.viewport.zoomBy(
|
2012-03-01 17:38:15 +04:00
|
|
|
1.0 / this.zoomPerClick
|
2011-12-23 05:08:06 +04:00
|
|
|
);
|
|
|
|
this.viewport.applyConstraints();
|
|
|
|
}
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-23 05:08:06 +04:00
|
|
|
|
2012-04-03 11:08:27 +04:00
|
|
|
|
2011-12-23 05:08:06 +04:00
|
|
|
function lightUp() {
|
2012-01-24 17:03:50 +04:00
|
|
|
this.buttons.emulateEnter();
|
|
|
|
this.buttons.emulateExit();
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-23 05:08:06 +04:00
|
|
|
|
2012-04-03 11:08:27 +04:00
|
|
|
|
2011-12-23 05:08:06 +04:00
|
|
|
function onHome() {
|
2014-08-21 21:11:21 +04:00
|
|
|
if ( this.viewport ) {
|
|
|
|
this.viewport.goHome();
|
|
|
|
}
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-23 05:08:06 +04:00
|
|
|
|
2012-04-03 11:08:27 +04:00
|
|
|
|
2013-11-03 05:01:04 +04:00
|
|
|
function onFullScreen() {
|
|
|
|
if ( this.isFullPage() && !$.isFullScreen() ) {
|
|
|
|
// Is fullPage but not fullScreen
|
|
|
|
this.setFullPage( false );
|
|
|
|
} else {
|
|
|
|
this.setFullScreen( !this.isFullPage() );
|
|
|
|
}
|
2012-01-24 17:03:50 +04:00
|
|
|
// correct for no mouseout event on change
|
2013-11-03 05:01:04 +04:00
|
|
|
if ( this.buttons ) {
|
2012-04-11 01:02:24 +04:00
|
|
|
this.buttons.emulateExit();
|
|
|
|
}
|
2012-03-20 03:03:58 +04:00
|
|
|
this.fullPageButton.element.focus();
|
2012-01-24 17:03:50 +04:00
|
|
|
if ( this.viewport ) {
|
2011-12-23 05:08:06 +04:00
|
|
|
this.viewport.applyConstraints();
|
|
|
|
}
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2011-12-13 07:40:02 +04:00
|
|
|
|
2014-02-21 00:57:39 +04:00
|
|
|
function onRotateLeft() {
|
|
|
|
if ( this.viewport ) {
|
|
|
|
var currRotation = this.viewport.getRotation();
|
2018-04-17 13:19:15 +03:00
|
|
|
|
2018-04-10 13:51:06 +03:00
|
|
|
if ( this.viewport.flipped ){
|
2018-08-22 00:39:46 +03:00
|
|
|
currRotation = $.positiveModulo(currRotation + this.rotationIncrement, 360);
|
2018-04-04 13:31:18 +03:00
|
|
|
} else {
|
2018-08-22 00:39:46 +03:00
|
|
|
currRotation = $.positiveModulo(currRotation - this.rotationIncrement, 360);
|
2014-02-21 00:57:39 +04:00
|
|
|
}
|
|
|
|
this.viewport.setRotation(currRotation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onRotateRight() {
|
|
|
|
if ( this.viewport ) {
|
|
|
|
var currRotation = this.viewport.getRotation();
|
2018-04-17 13:19:15 +03:00
|
|
|
|
2018-04-10 13:51:06 +03:00
|
|
|
if ( this.viewport.flipped ){
|
2018-08-22 00:39:46 +03:00
|
|
|
currRotation = $.positiveModulo(currRotation - this.rotationIncrement, 360);
|
2018-04-04 13:31:18 +03:00
|
|
|
} else {
|
2018-08-22 00:39:46 +03:00
|
|
|
currRotation = $.positiveModulo(currRotation + this.rotationIncrement, 360);
|
2014-02-21 00:57:39 +04:00
|
|
|
}
|
|
|
|
this.viewport.setRotation(currRotation);
|
|
|
|
}
|
|
|
|
}
|
2018-04-10 14:04:58 +03:00
|
|
|
/**
|
|
|
|
* Note: When pressed flip control button
|
|
|
|
*/
|
2018-04-11 13:25:46 +03:00
|
|
|
function onFlip() {
|
|
|
|
this.viewport.toggleFlip();
|
2018-04-06 14:02:45 +03:00
|
|
|
}
|
2012-04-03 11:08:27 +04:00
|
|
|
|
|
|
|
function onPrevious(){
|
2014-11-15 04:19:04 +03:00
|
|
|
var previous = this._sequenceIndex - 1;
|
2013-05-30 03:10:45 +04:00
|
|
|
if(this.navPrevNextWrap && previous < 0){
|
|
|
|
previous += this.tileSources.length;
|
|
|
|
}
|
2012-06-05 15:52:00 +04:00
|
|
|
this.goToPage( previous );
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2012-04-03 11:08:27 +04:00
|
|
|
|
|
|
|
|
|
|
|
function onNext(){
|
2014-11-15 04:19:04 +03:00
|
|
|
var next = this._sequenceIndex + 1;
|
2013-05-30 03:10:45 +04:00
|
|
|
if(this.navPrevNextWrap && next >= this.tileSources.length){
|
|
|
|
next = 0;
|
|
|
|
}
|
2012-06-05 15:52:00 +04:00
|
|
|
this.goToPage( next );
|
2013-01-29 21:32:58 +04:00
|
|
|
}
|
2012-04-03 11:08:27 +04:00
|
|
|
|
|
|
|
|
2011-12-06 07:50:25 +04:00
|
|
|
}( OpenSeadragon ));
|