mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-21 20:56:09 +03:00
Added x and y to drawer.
This commit is contained in:
parent
ef8bd1a198
commit
ea6ee54136
@ -49,7 +49,7 @@ var DEVICE_SCREEN = $.getWindowSize(),
|
||||
|
||||
/**
|
||||
* @class Drawer
|
||||
* @classdesc Handles rendering of tiles for an {@link OpenSeadragon.Viewer}.
|
||||
* @classdesc Handles rendering of tiles for an {@link OpenSeadragon.Viewer}.
|
||||
* A new instance is created for each TileSource opened (see {@link OpenSeadragon.Viewer#drawer}).
|
||||
*
|
||||
* @memberof OpenSeadragon
|
||||
@ -74,6 +74,9 @@ $.Drawer = function( options ) {
|
||||
|
||||
$.extend( true, this, {
|
||||
|
||||
x: 0,
|
||||
y: 0,
|
||||
|
||||
//internal state properties
|
||||
viewer: null,
|
||||
imageLoader: new $.ImageLoader(),
|
||||
@ -380,6 +383,11 @@ function updateViewport( drawer ) {
|
||||
levelOpacity,
|
||||
levelVisibility;
|
||||
|
||||
viewportTL.x -= drawer.x;
|
||||
viewportTL.y -= drawer.y;
|
||||
viewportBR.x -= drawer.x;
|
||||
viewportBR.y -= drawer.y;
|
||||
|
||||
// Reset tile's internal drawn state
|
||||
while ( drawer.lastDrawn.length > 0 ) {
|
||||
tile = drawer.lastDrawn.pop();
|
||||
@ -636,7 +644,8 @@ function updateTile( drawer, drawLevel, haveDrawn, x, y, level, levelOpacity, le
|
||||
drawer.source.tileOverlap,
|
||||
drawer.viewport,
|
||||
viewportCenter,
|
||||
levelVisibility
|
||||
levelVisibility,
|
||||
drawer
|
||||
);
|
||||
|
||||
if ( tile.loaded ) {
|
||||
@ -793,9 +802,13 @@ function onTileLoad( drawer, tile, time, image ) {
|
||||
}
|
||||
|
||||
|
||||
function positionTile( tile, overlap, viewport, viewportCenter, levelVisibility ){
|
||||
var boundsTL = tile.bounds.getTopLeft(),
|
||||
boundsSize = tile.bounds.getSize(),
|
||||
function positionTile( tile, overlap, viewport, viewportCenter, levelVisibility, drawer ){
|
||||
var boundsTL = tile.bounds.getTopLeft();
|
||||
|
||||
boundsTL.x += drawer.x;
|
||||
boundsTL.y += drawer.y;
|
||||
|
||||
var boundsSize = tile.bounds.getSize(),
|
||||
positionC = viewport.pixelFromPoint( boundsTL, true ),
|
||||
positionT = viewport.pixelFromPoint( boundsTL, false ),
|
||||
sizeC = viewport.deltaPixelsFromPoints( boundsSize, true ),
|
||||
|
@ -111,7 +111,7 @@ $.Viewer = function( options ) {
|
||||
/**
|
||||
* A <textarea> element, the element where keyboard events are handled.<br><br>
|
||||
* Child element of {@link OpenSeadragon.Viewer#container},
|
||||
* positioned below {@link OpenSeadragon.Viewer#canvas}.
|
||||
* positioned below {@link OpenSeadragon.Viewer#canvas}.
|
||||
* @member {Element} keyboardCommandArea
|
||||
* @memberof OpenSeadragon.Viewer#
|
||||
*/
|
||||
@ -120,7 +120,7 @@ $.Viewer = function( options ) {
|
||||
* 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>
|
||||
* The parent of {@link OpenSeadragon.Drawer#canvas} instances.
|
||||
* The parent of {@link OpenSeadragon.Drawer#canvas} instances.
|
||||
* @member {Element} canvas
|
||||
* @memberof OpenSeadragon.Viewer#
|
||||
*/
|
||||
@ -246,14 +246,14 @@ $.Viewer = function( options ) {
|
||||
if( this.tileSources.length > 1 ){
|
||||
THIS[ this.hash ].sequenced = true;
|
||||
}
|
||||
|
||||
|
||||
//Keeps the initial page within bounds
|
||||
if ( this.initialPage > this.tileSources.length - 1 ){
|
||||
this.initialPage = this.tileSources.length - 1;
|
||||
}
|
||||
|
||||
|
||||
initialTileSource = this.tileSources[ this.initialPage ];
|
||||
|
||||
|
||||
//Update the sequence (aka currrent page) property
|
||||
THIS[ this.hash ].sequence = this.initialPage;
|
||||
} else {
|
||||
@ -529,12 +529,12 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
||||
* @fires OpenSeadragon.Viewer.event:close
|
||||
*/
|
||||
close: function ( ) {
|
||||
|
||||
|
||||
if ( !THIS[ this.hash ] ) {
|
||||
//this viewer has already been destroyed: returning immediately
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
if ( this._updateRequestId !== null ) {
|
||||
$.cancelAnimationFrame( this._updateRequestId );
|
||||
this._updateRequestId = null;
|
||||
@ -579,7 +579,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
||||
|
||||
/**
|
||||
* Function to destroy the viewer and clean up everything created by OpenSeadragon.
|
||||
*
|
||||
*
|
||||
* Example:
|
||||
* var viewer = OpenSeadragon({
|
||||
* [...]
|
||||
@ -596,8 +596,8 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
||||
|
||||
//TODO: implement this...
|
||||
//this.unbindSequenceControls()
|
||||
//this.unbindStandardControls()
|
||||
|
||||
//this.unbindStandardControls()
|
||||
|
||||
this.removeAllHandlers();
|
||||
|
||||
// Go through top element (passed to us) and remove all children
|
||||
@ -1096,24 +1096,26 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
||||
return;
|
||||
}
|
||||
|
||||
for ( var i = 0; i < _this.drawers.length; i++ ) {
|
||||
var otherAspectRatio = _this.drawers[ i ].source.aspectRatio;
|
||||
var diff = otherAspectRatio - tileSource.aspectRatio;
|
||||
if ( Math.abs( diff ) > _this.layersAspectRatioEpsilon ) {
|
||||
raiseAddLayerFailed({
|
||||
message: "Aspect ratio mismatch with layer " + i + ".",
|
||||
source: tileSource,
|
||||
options: options
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
// for ( var i = 0; i < _this.drawers.length; i++ ) {
|
||||
// var otherAspectRatio = _this.drawers[ i ].source.aspectRatio;
|
||||
// var diff = otherAspectRatio - tileSource.aspectRatio;
|
||||
// if ( Math.abs( diff ) > _this.layersAspectRatioEpsilon ) {
|
||||
// raiseAddLayerFailed({
|
||||
// message: "Aspect ratio mismatch with layer " + i + ".",
|
||||
// source: tileSource,
|
||||
// options: options
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
var drawer = new $.Drawer({
|
||||
viewer: _this,
|
||||
source: tileSource,
|
||||
viewport: _this.viewport,
|
||||
element: _this.drawersContainer,
|
||||
x: options.x !== undefined ? options.x : 0,
|
||||
y: options.y !== undefined ? options.y : 0,
|
||||
opacity: options.opacity !== undefined ?
|
||||
options.opacity : _this.opacity,
|
||||
maxImageCacheCount: _this.maxImageCacheCount,
|
||||
@ -1249,7 +1251,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
||||
/**
|
||||
* Remove a layer. If there is only one layer, close the viewer.
|
||||
* @function
|
||||
* @param {OpenSeadragon.Drawer} drawer The underlying drawer of the layer
|
||||
* @param {OpenSeadragon.Drawer} drawer The underlying drawer of the layer
|
||||
* to remove
|
||||
* @returns {OpenSeadragon.Viewer} Chainable.
|
||||
* @fires OpenSeadragon.Viewer.event:remove-layer
|
||||
@ -1540,7 +1542,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Gets the active page of a sequence
|
||||
* @function
|
||||
@ -1779,7 +1781,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Display a message in the viewport
|
||||
* @function OpenSeadragon.Viewer.prototype._showMessage
|
||||
|
@ -326,6 +326,10 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
||||
* @fires OpenSeadragon.Viewer.event:constrain
|
||||
*/
|
||||
applyConstraints: function( immediately ) {
|
||||
if (true) {
|
||||
return; // TEMP
|
||||
}
|
||||
|
||||
var actualZoom = this.getZoom(),
|
||||
constrainedZoom = Math.max(
|
||||
Math.min( actualZoom, this.getMaxZoom() ),
|
||||
@ -653,7 +657,7 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
||||
}
|
||||
this.degrees = degrees;
|
||||
this.viewer.forceRedraw();
|
||||
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
@ -991,7 +995,7 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
||||
return viewerCoordinates.plus(
|
||||
OpenSeadragon.getElementPosition( this.viewer.element ));
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Convert a viewport zoom to an image zoom.
|
||||
* Image zoom: ratio of the original image size to displayed image size.
|
||||
@ -1009,7 +1013,7 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
||||
var viewportToImageZoomRatio = containerWidth / imageWidth;
|
||||
return viewportZoom * viewportToImageZoomRatio;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Convert an image zoom to a viewport zoom.
|
||||
* Image zoom: ratio of the original image size to displayed image size.
|
||||
|
22
test/demo/collections/index.html
Normal file
22
test/demo/collections/index.html
Normal file
@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>OpenSeadragon Collections Demo</title>
|
||||
<script type="text/javascript" src='../../../build/openseadragon/openseadragon.js'></script>
|
||||
<script type="text/javascript" src='../../lib/jquery-1.9.1.min.js'></script>
|
||||
<script type="text/javascript" src='main.js'></script>
|
||||
<style type="text/css">
|
||||
|
||||
html,
|
||||
body,
|
||||
.openseadragon1 {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="contentDiv" class="openseadragon1"></div>
|
||||
</body>
|
||||
</html>
|
44
test/demo/collections/main.js
Normal file
44
test/demo/collections/main.js
Normal file
@ -0,0 +1,44 @@
|
||||
(function() {
|
||||
|
||||
var App = {
|
||||
init: function() {
|
||||
var self = this;
|
||||
|
||||
this.viewer = OpenSeadragon( {
|
||||
// debugMode: true,
|
||||
id: "contentDiv",
|
||||
prefixUrl: "../../../build/openseadragon/images/",
|
||||
tileSources: "../../data/tall.dzi"
|
||||
} );
|
||||
|
||||
this.viewer.addHandler( "open", function() {
|
||||
self.addLayer();
|
||||
});
|
||||
},
|
||||
|
||||
// ----------
|
||||
addLayer: function() {
|
||||
var self = this;
|
||||
|
||||
var options = {
|
||||
tileSource: '../../data/wide.dzi',
|
||||
opacity: 1,
|
||||
x: 0.5,
|
||||
y: 0.5
|
||||
};
|
||||
|
||||
var addLayerHandler = function( event ) {
|
||||
if ( event.options === options ) {
|
||||
self.viewer.removeHandler( "add-layer", addLayerHandler );
|
||||
}
|
||||
};
|
||||
this.viewer.addHandler( "add-layer", addLayerHandler );
|
||||
this.viewer.addLayer( options );
|
||||
}
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
App.init();
|
||||
});
|
||||
|
||||
})();
|
Loading…
Reference in New Issue
Block a user