Skip to content

Commit

Permalink
Fix ember-remodal doesn't remove padding-right when the modal closes …
Browse files Browse the repository at this point in the history
…in some cases

Fixes vodkabears#263.
  • Loading branch information
nag5000 committed May 2, 2017
1 parent ed63e53 commit e2dcac7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
14 changes: 11 additions & 3 deletions dist/remodal.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,16 +252,20 @@

var $html = $('html');
var lockedClass = namespacify('is-locked');
var scrollbarWidth;
var paddingRight;
var $body;

if (!$html.hasClass(lockedClass)) {
$body = $(document.body);

scrollbarWidth = getScrollbarWidth();

// Zepto does not support '-=', '+=' in the `css` method
paddingRight = parseInt($body.css('padding-right'), 10) + getScrollbarWidth();
paddingRight = parseInt($body.css('padding-right'), 10) + scrollbarWidth;

$body.css('padding-right', paddingRight + 'px');
$body.attr('data-scrollbar-width', scrollbarWidth);
$html.addClass(lockedClass);
}
}
Expand All @@ -277,16 +281,20 @@

var $html = $('html');
var lockedClass = namespacify('is-locked');
var scrollbarWidth;
var paddingRight;
var $body;

if ($html.hasClass(lockedClass)) {
$body = $(document.body);

scrollbarWidth = Number($body.attr('data-scrollbar-width')) || 0;

// Zepto does not support '-=', '+=' in the `css` method
paddingRight = parseInt($body.css('padding-right'), 10) - getScrollbarWidth();
paddingRight = parseInt($body.css('padding-right'), 10) - scrollbarWidth;

$body.css('padding-right', paddingRight + 'px');
$body.css('padding-right', paddingRight ? paddingRight + 'px' : '');
$body.removeAttr('data-scrollbar-width');
$html.removeClass(lockedClass);
}
}
Expand Down
2 changes: 1 addition & 1 deletion dist/remodal.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions src/remodal.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,20 @@

var $html = $('html');
var lockedClass = namespacify('is-locked');
var scrollbarWidth;
var paddingRight;
var $body;

if (!$html.hasClass(lockedClass)) {
$body = $(document.body);

scrollbarWidth = getScrollbarWidth();

// Zepto does not support '-=', '+=' in the `css` method
paddingRight = parseInt($body.css('padding-right'), 10) + getScrollbarWidth();
paddingRight = parseInt($body.css('padding-right'), 10) + scrollbarWidth;

$body.css('padding-right', paddingRight + 'px');
$body.attr('data-scrollbar-width', scrollbarWidth);
$html.addClass(lockedClass);
}
}
Expand All @@ -268,16 +272,20 @@

var $html = $('html');
var lockedClass = namespacify('is-locked');
var scrollbarWidth;
var paddingRight;
var $body;

if ($html.hasClass(lockedClass)) {
$body = $(document.body);

scrollbarWidth = Number($body.attr('data-scrollbar-width')) || 0;

// Zepto does not support '-=', '+=' in the `css` method
paddingRight = parseInt($body.css('padding-right'), 10) - getScrollbarWidth();
paddingRight = parseInt($body.css('padding-right'), 10) - scrollbarWidth;

$body.css('padding-right', paddingRight + 'px');
$body.css('padding-right', paddingRight ? paddingRight + 'px' : '');
$body.removeAttr('data-scrollbar-width');
$html.removeClass(lockedClass);
}
}
Expand Down

0 comments on commit e2dcac7

Please sign in to comment.