Skip to content

Commit

Permalink
Check if activeElement is available in max-width
Browse files Browse the repository at this point in the history
  • Loading branch information
drublic committed Jun 6, 2014
1 parent 48b2eff commit d5dae8e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## HEAD
* Check if activeElement is available in max-width

## 1.1.5 - 05.06.2014
* Fix position of close button on small screens
Expand Down
8 changes: 6 additions & 2 deletions plugins/modal-maxwidth.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
var _scale = function () {
var element = CSSModal.activeElement;

// Eject if no active element is set
if (!element) {
return;
}

_currentMaxWidth = element.getAttribute('data-cssmodal-maxwidth');
_currentMaxWidth = parseInt(_currentMaxWidth, 10);

Expand All @@ -69,11 +74,10 @@
var closeButtonMarginRight = 10;

// Skip if there is no max width or the window is wider
if (!_currentMaxWidth || innerWidth > _currentMaxWidth) {
if (!element || !_currentMaxWidth || innerWidth > _currentMaxWidth) {
return;
}


// Window width minus margin left and right
_margin = parseInt(element.getAttribute('data-cssmodal-margin'), 10) || _margin;
_currentMaxWidth = innerWidth - (_margin * 2);
Expand Down

0 comments on commit d5dae8e

Please sign in to comment.