-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix(backdrop, dialog, css): improve position and animations of backdrop #3841
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,11 +17,35 @@ | |
* | ||
*/ | ||
|
||
angular.module('material.components.backdrop', [ | ||
'material.core' | ||
]) | ||
.directive('mdBackdrop', BackdropDirective); | ||
|
||
function BackdropDirective($mdTheming) { | ||
return $mdTheming; | ||
} | ||
angular | ||
.module('material.components.backdrop', ['material.core']) | ||
.directive('mdBackdrop', function BackdropDirective($mdTheming, $animate, $rootElement, $window, $log, $$rAF) { | ||
|
||
return { | ||
restrict: 'E', | ||
link: postLink | ||
}; | ||
|
||
function postLink(scope, element, attrs) { | ||
// backdrop may be outside the $rootElement, tell ngAnimate to animate regardless | ||
if( $animate.pin ) $animate.pin(element,$rootElement); | ||
|
||
$$rAF(function(){ | ||
// Often $animate.enter() is used to append the backDrop element | ||
// so let's wait until $animate is done... | ||
|
||
var parent = element.parent()[0]; | ||
if ( parent ) { | ||
var position = $window.getComputedStyle(parent).getPropertyValue('position'); | ||
if (position == 'static') { | ||
// backdrop uses position:absolute and will not work properly with parent position:static (default) | ||
var positionError = "<md-backdrop> may not work properly in a scrolled, static-positioned parent container."; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps this should be |
||
$log.warn( positionError ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
} | ||
} | ||
|
||
$mdTheming.inherit(element, element.parent()); | ||
}); | ||
|
||
}; | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,9 @@ md-backdrop { | |
z-index: $z-index-sidenav - 1; | ||
} | ||
|
||
opacity: 1; | ||
transition: opacity 600ms $swift-ease-in-timing-function; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A bit nit-picky, but this probably belongs inside the |
||
|
||
background-color: rgba(0,0,0,0); | ||
|
||
position: absolute; | ||
|
@@ -25,27 +28,27 @@ md-backdrop { | |
right: 0; | ||
|
||
&.md-click-catcher { | ||
top: 0; | ||
position: fixed; | ||
} | ||
|
||
&.ng-enter { | ||
animation: $swift-ease-out-timing-function mdBackdropFadeIn 0.5s both; | ||
opacity: 0; | ||
&.ng-enter-active { | ||
opacity: 1; | ||
} | ||
} | ||
|
||
&.ng-leave { | ||
animation: $swift-ease-in-timing-function mdBackdropFadeOut 0.4s both; | ||
opacity: 1; | ||
transition: opacity 400ms linear; | ||
|
||
&.ng-leave-active { | ||
opacity: 0; | ||
} | ||
} | ||
|
||
&.md-opaque { | ||
background-color: rgba(0,0,0,0.42); | ||
} | ||
} | ||
|
||
@keyframes mdBackdropFadeIn { | ||
from { opacity: 0; } | ||
to { opacity: 1; } | ||
} | ||
@keyframes mdBackdropFadeOut { | ||
from { opacity: 1; } | ||
to { opacity: 0; } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#popupContainer { | ||
position:relative; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ $dialog-padding: $baseline-grid * 3; | |
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
position: fixed; | ||
position: absolute; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to hear from @rschmukler on this one, just to confirm that this is safe and we aren't missing some edge case. |
||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this sets the local testing and online docs to use 1.4.3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I think that's good - as long as it's stable, we should be running against the latest version of Angular.