Added x and y to drawer.

This commit is contained in:
Ian Gilman 2014-07-17 16:24:28 -07:00
parent ef8bd1a198
commit ea6ee54136
5 changed files with 118 additions and 33 deletions

View file

@ -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 ),

View file

@ -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,

View file

@ -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() ),

View 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>

View 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();
});
})();