mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 13:16:10 +03:00
Merge pull request #758 from openseadragon/ian3
You can now change viewport margins after the viewer is created
This commit is contained in:
commit
9fa3136e78
@ -34,6 +34,7 @@ OPENSEADRAGON CHANGELOG
|
|||||||
* Fixed issue with including overlays in your tileSources array when creating/opening in the viewer (#745)
|
* Fixed issue with including overlays in your tileSources array when creating/opening in the viewer (#745)
|
||||||
* Fixed issue in iOS devices that would cause all touch events to fail after a Multitasking Gesture was triggered (#744)
|
* Fixed issue in iOS devices that would cause all touch events to fail after a Multitasking Gesture was triggered (#744)
|
||||||
* Fixed an issue with TiledImage setPosition/setWidth/setHeight not reliably triggering a redraw (#720)
|
* Fixed an issue with TiledImage setPosition/setWidth/setHeight not reliably triggering a redraw (#720)
|
||||||
|
* You can now change viewport margins after the viewer is created (#721)
|
||||||
|
|
||||||
2.0.0:
|
2.0.0:
|
||||||
|
|
||||||
|
@ -111,10 +111,7 @@ $.Viewport = function( options ) {
|
|||||||
|
|
||||||
}, options );
|
}, options );
|
||||||
|
|
||||||
this._containerInnerSize = new $.Point(
|
this._updateContainerInnerSize();
|
||||||
Math.max(1, this.containerSize.x - (this._margins.left + this._margins.right)),
|
|
||||||
Math.max(1, this.containerSize.y - (this._margins.top + this._margins.bottom))
|
|
||||||
);
|
|
||||||
|
|
||||||
this.centerSpringX = new $.Spring({
|
this.centerSpringX = new $.Spring({
|
||||||
initial: 0,
|
initial: 0,
|
||||||
@ -314,6 +311,34 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* The margins push the "home" region in from the sides by the specified amounts.
|
||||||
|
* @returns {Object} Properties (Numbers, in screen coordinates): left, top, right, bottom.
|
||||||
|
*/
|
||||||
|
getMargins: function() {
|
||||||
|
return $.extend({}, this._margins); // Make a copy so we are not returning our original
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* The margins push the "home" region in from the sides by the specified amounts.
|
||||||
|
* @param {Object} margins - Properties (Numbers, in screen coordinates): left, top, right, bottom.
|
||||||
|
*/
|
||||||
|
setMargins: function(margins) {
|
||||||
|
$.console.assert($.type(margins) === 'object', '[Viewport.setMargins] margins must be an object');
|
||||||
|
|
||||||
|
this._margins = $.extend({
|
||||||
|
left: 0,
|
||||||
|
top: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 0
|
||||||
|
}, margins);
|
||||||
|
|
||||||
|
this._updateContainerInnerSize();
|
||||||
|
this.viewer.forceRedraw();
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
* @param {Boolean} current - Pass true for the current location; defaults to false (target location).
|
* @param {Boolean} current - Pass true for the current location; defaults to false (target location).
|
||||||
@ -830,10 +855,7 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
this.containerSize.x = newContainerSize.x;
|
this.containerSize.x = newContainerSize.x;
|
||||||
this.containerSize.y = newContainerSize.y;
|
this.containerSize.y = newContainerSize.y;
|
||||||
|
|
||||||
this._containerInnerSize = new $.Point(
|
this._updateContainerInnerSize();
|
||||||
Math.max(1, newContainerSize.x - (this._margins.left + this._margins.right)),
|
|
||||||
Math.max(1, newContainerSize.y - (this._margins.top + this._margins.bottom))
|
|
||||||
);
|
|
||||||
|
|
||||||
if ( maintain ) {
|
if ( maintain ) {
|
||||||
// TODO: widthDeltaFactor will always be 1; probably not what's intended
|
// TODO: widthDeltaFactor will always be 1; probably not what's intended
|
||||||
@ -863,6 +885,14 @@ $.Viewport.prototype = /** @lends OpenSeadragon.Viewport.prototype */{
|
|||||||
return this.fitBounds( newBounds, true );
|
return this.fitBounds( newBounds, true );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// private
|
||||||
|
_updateContainerInnerSize: function() {
|
||||||
|
this._containerInnerSize = new $.Point(
|
||||||
|
Math.max(1, this.containerSize.x - (this._margins.left + this._margins.right)),
|
||||||
|
Math.max(1, this.containerSize.y - (this._margins.top + this._margins.bottom))
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function
|
* @function
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user