Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(toast): added position relative to toast parent
Browse files Browse the repository at this point in the history
Toast is aligned by `position: absolute` therefore its parent must have `position: relative` to enable the toast align properly,

*  Added `position: relative` to the parent only if there's no computed style for position (checking for `static` because this is the default computed position)

fixes #4542. closes #5660.
  • Loading branch information
EladBezalel authored and ThomasBurleson committed Nov 13, 2015
1 parent a7fc111 commit 617ab2c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/components/toast/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,12 @@ function MdToastProvider($$interimElementProvider) {

// 'top left' -> 'md-top md-left'
options.parent.addClass(options.openClass);

// static is the default position
if ($mdUtil.hasComputedStyle(options.parent, 'position', 'static')) {
options.parent.css('position', 'relative');
}

element.on(SWIPE_EVENTS, options.onSwipe);
element.addClass(options.position.split(' ').map(function(pos) {
return 'md-' + pos;
Expand All @@ -277,7 +283,12 @@ function MdToastProvider($$interimElementProvider) {
element.off(SWIPE_EVENTS, options.onSwipe);
if (options.openClass) options.parent.removeClass(options.openClass);

return (options.$destroy == true) ? element.remove() : $animate.leave(element);
return ((options.$destroy == true) ? element.remove() : $animate.leave(element))
.then(function () {
if ($mdUtil.hasComputedStyle(options.parent, 'position', 'static')) {
options.parent.css('position', '');
}
});
}

function toastOpenClass(position) {
Expand Down

0 comments on commit 617ab2c

Please sign in to comment.