Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Update getDimensions function to ensure that w[] has non-zero values #15

Open
wants to merge 1 commit into from

1 participant

@yellis

Ran into a bug using simplemodal on IE9 where wndw.Width() and .height() as used in the getDimensions function returned zero. This resulted in top/left being set to the wrong numbers, modal being off-center. Corrected by checking in getDimensions that values are > 0 before initializing the w[] array with them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 11, 2012
  1. @yellis

    Update getDimensions function to ensure that w[] array is not storing…

    yellis authored
    … non-zero values (can happen with IE sometimes)
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 1 deletion.
  1. +10 −1 src/jquery.simplemodal.js
View
11 src/jquery.simplemodal.js
@@ -497,7 +497,16 @@
h = typeof window.innerHeight === 'undefined' ? wndw.height() : window.innerHeight;
d = [doc.height(), doc.width()];
- w = [h, wndw.width()];
+
+ // make sure that w is recording real numbers.
+ // In case wndw.height() or .width() is not working, use numbers from doc instead (better than nothing)
+ var heightToUse = h == 0 ? d[0] : h;
+ var widthToUse = wndw.width();
+ if (widthToUse == 0) {
+ widthToUse = d[1];
+ }
+ w = [heightToUse, widthToUse];
+
},
getVal: function (v, d) {
return v ? (typeof v === 'number' ? v
Something went wrong with that request. Please try again.