Skip to content

Commit d5d7a16

Browse files
committed
Added maxWidth and maxHeight for sizes.
Sometimes there may be the need to limit the maximum size of a modal to be consistent in size/layout for the user.
1 parent 5a243fc commit d5d7a16

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

js/jquery.nyroModal.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ jQuery(function($, undefined) {
9999
h: undefined, // height
100100
minW: undefined, // minimum Width
101101
minH: undefined, // minimum height
102+
maxW: undefined, // maximum width
103+
maxH: undefined, // maximum height
102104
wMargin: undefined, // Horizontal margin
103105
hMargin: undefined // Vertical margin
104106
},
@@ -183,8 +185,8 @@ jQuery(function($, undefined) {
183185
// Update sizes element to not go outsize the viewport.
184186
// Will call 'size' callback filter
185187
size: function() {
186-
var maxHeight = this.getInternal().fullSize.viewH - this.sizes.hMargin,
187-
maxWidth = this.getInternal().fullSize.viewW - this.sizes.wMargin;
188+
var maxHeight = (typeof this.sizes.maxH !== 'undefined') ? this.sizes.maxH : this.getInternal().fullSize.viewH - this.sizes.hMargin,
189+
maxWidth = (typeof this.sizes.maxW !== 'undefined') ? this.sizes.maxW : this.getInternal().fullSize.viewW - this.sizes.wMargin;
188190
if (this.sizes.minW && this.sizes.minW > this.sizes.w)
189191
this.sizes.w = this.sizes.minW;
190192
if (this.sizes.minH && this.sizes.minH > this.sizes.h)
@@ -944,4 +946,4 @@ function ucfirst(str) {
944946
str += '';
945947
var f = str.charAt(0).toUpperCase();
946948
return f + str.substr(1);
947-
}
949+
}

0 commit comments

Comments
 (0)