mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-02-16 14:53:14 +03:00
Updated viewport.getConstrainedBounds so it takes in current
instead of immediately
This commit is contained in:
parent
4e060d6ca2
commit
97c839b9f3
@ -485,10 +485,9 @@ $.Viewport.prototype = {
|
|||||||
* @function
|
* @function
|
||||||
* @private
|
* @private
|
||||||
* @param {OpenSeadragon.Rect} bounds
|
* @param {OpenSeadragon.Rect} bounds
|
||||||
* @param {Boolean} immediately
|
|
||||||
* @return {OpenSeadragon.Rect} constrained bounds.
|
* @return {OpenSeadragon.Rect} constrained bounds.
|
||||||
*/
|
*/
|
||||||
_applyBoundaryConstraints: function(bounds, immediately) {
|
_applyBoundaryConstraints: function(bounds) {
|
||||||
var newBounds = new $.Rect(
|
var newBounds = new $.Rect(
|
||||||
bounds.x,
|
bounds.x,
|
||||||
bounds.y,
|
bounds.y,
|
||||||
@ -531,6 +530,16 @@ $.Viewport.prototype = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return newBounds;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @private
|
||||||
|
* @param {Boolean} [immediately=false] - whether the function that triggered this event was
|
||||||
|
* called with the "immediately" flag
|
||||||
|
*/
|
||||||
|
_raiseConstraintsEvent: function(immediately) {
|
||||||
if (this.viewer) {
|
if (this.viewer) {
|
||||||
/**
|
/**
|
||||||
* Raised when the viewport constraints are applied (see {@link OpenSeadragon.Viewport#applyConstraints}).
|
* Raised when the viewport constraints are applied (see {@link OpenSeadragon.Viewport#applyConstraints}).
|
||||||
@ -539,15 +548,14 @@ $.Viewport.prototype = {
|
|||||||
* @memberof OpenSeadragon.Viewer
|
* @memberof OpenSeadragon.Viewer
|
||||||
* @type {object}
|
* @type {object}
|
||||||
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
|
||||||
* @property {Boolean} immediately
|
* @property {Boolean} immediately - whether the function that triggered this event was
|
||||||
|
* called with the "immediately" flag
|
||||||
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
||||||
*/
|
*/
|
||||||
this.viewer.raiseEvent( 'constrain', {
|
this.viewer.raiseEvent( 'constrain', {
|
||||||
immediately: immediately
|
immediately: immediately
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return newBounds;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -567,8 +575,8 @@ $.Viewport.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var bounds = this.getBoundsNoRotate();
|
var bounds = this.getBoundsNoRotate();
|
||||||
var constrainedBounds = this._applyBoundaryConstraints(
|
var constrainedBounds = this._applyBoundaryConstraints(bounds);
|
||||||
bounds, immediately);
|
this._raiseConstraintsEvent(immediately);
|
||||||
|
|
||||||
if (bounds.x !== constrainedBounds.x ||
|
if (bounds.x !== constrainedBounds.x ||
|
||||||
bounds.y !== constrainedBounds.y ||
|
bounds.y !== constrainedBounds.y ||
|
||||||
@ -638,8 +646,9 @@ $.Viewport.prototype = {
|
|||||||
newBounds.y = center.y - newBounds.height / 2;
|
newBounds.y = center.y - newBounds.height / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
newBounds = this._applyBoundaryConstraints(newBounds, immediately);
|
newBounds = this._applyBoundaryConstraints(newBounds);
|
||||||
center = newBounds.getCenter();
|
center = newBounds.getCenter();
|
||||||
|
this._raiseConstraintsEvent(immediately);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (immediately) {
|
if (immediately) {
|
||||||
@ -736,17 +745,16 @@ $.Viewport.prototype = {
|
|||||||
/**
|
/**
|
||||||
* Returns bounds taking constraints into account
|
* Returns bounds taking constraints into account
|
||||||
* Added to improve constrained panning
|
* Added to improve constrained panning
|
||||||
* @param {Boolean} immediately
|
* @param {Boolean} current - Pass true for the current location; defaults to false (target location).
|
||||||
* @return {OpenSeadragon.Viewport} Chainable.
|
* @return {OpenSeadragon.Viewport} Chainable.
|
||||||
*/
|
*/
|
||||||
// Added to improve constrained panning
|
getConstrainedBounds: function(current) {
|
||||||
getConstrainedBounds: function( immediately ) {
|
|
||||||
var bounds,
|
var bounds,
|
||||||
constrainedBounds;
|
constrainedBounds;
|
||||||
|
|
||||||
bounds = this.getBounds();
|
bounds = this.getBounds(current);
|
||||||
|
|
||||||
constrainedBounds = this._applyBoundaryConstraints( bounds, immediately );
|
constrainedBounds = this._applyBoundaryConstraints(bounds);
|
||||||
|
|
||||||
return constrainedBounds;
|
return constrainedBounds;
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user