Permalink
Browse files

preserve aspect ratio only on non-draggable content

  • Loading branch information...
1 parent 4ed5027 commit e873b2f53a12f6a55b2566ea2adc226042f3c11e @mjackson committed Feb 23, 2010
Showing with 21 additions and 13 deletions.
  1. +13 −9 source/core.js
  2. +8 −4 source/skin.js
View
@@ -609,16 +609,20 @@ S.previous = function() {
/**
* Calculates the dimensions for Shadowbox.
*
- * @param {Number} height The height of the object
- * @param {Number} width The width of the object
- * @param {Number} maxHeight The maximum available height
- * @param {Number} maxWidth The maximum available width
- * @param {Number} topBottom The extra top/bottom required for borders/toolbars
- * @param {Number} leftRight The extra left/right required for borders/toolbars
- * @return {Object} The new dimensions object
+ * @param {Number} height The height of the object
+ * @param {Number} width The width of the object
+ * @param {Number} maxHeight The maximum available height
+ * @param {Number} maxWidth The maximum available width
+ * @param {Number} topBottom The extra top/bottom required for borders/toolbars
+ * @param {Number} leftRight The extra left/right required for borders/toolbars
+ * @param {Number} padding The amount of padding (in pixels) to maintain around
+ * the edge of the viewport
+ * @param {Boolean} preserveAspect True to preserve the original aspect ratio when the
+ * given dimensions are too large
+ * @return {Object} The new dimensions object
* @public
*/
-S.setDimensions = function(height, width, maxHeight, maxWidth, topBottom, leftRight, padding) {
+S.setDimensions = function(height, width, maxHeight, maxWidth, topBottom, leftRight, padding, preserveAspect) {
var originalHeight = height,
originalWidth = width;
@@ -636,7 +640,7 @@ S.setDimensions = function(height, width, maxHeight, maxWidth, topBottom, leftRi
oversized = (changeHeight > 0 || changeWidth > 0);
// adjust height/width if too large
- if (oversized) {
+ if (preserveAspect && oversized) {
// preserve aspect ratio according to greatest change
if (changeHeight > changeWidth) {
width = Math.round((originalWidth / originalHeight) * height);
View
@@ -381,14 +381,18 @@ function setDimensions(height, width) {
topBottom = wrapper.offsetHeight - bodyInner.offsetHeight,
leftRight = wrapper.offsetWidth - bodyInner.offsetWidth,
+ // overlay should provide proper window dimensions here
+ maxHeight = overlay.offsetHeight,
+ maxWidth = overlay.offsetWidth,
+
// default to the default viewport padding
padding = parseInt(S.options.viewportPadding) || 20,
- // overlay should provide proper window dimensions here
- maxHeight = overlay.offsetHeight,
- maxWidth = overlay.offsetWidth;
+ // only preserve aspect ratio if there is something to display and
+ // it's not draggable
+ preserveAspect = (S.player && S.options.handleOversize != "drag");
- return S.setDimensions(height, width, maxHeight, maxWidth, topBottom, leftRight, padding);
+ return S.setDimensions(height, width, maxHeight, maxWidth, topBottom, leftRight, padding, preserveAspect);
}
/**

0 comments on commit e873b2f

Please sign in to comment.