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

Commit 3aab9e4

Browse files
author
Robert Messerle
committed
fix(dialog): adds logic to account for image load delays that could
impact content height
1 parent 6a4bae8 commit 3aab9e4

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/components/dialog/demoBasicUsage/dialog1.tmpl.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ <h2>Mango (Fruit)</h2>
3131
More on Wikipedia
3232
</md-button>
3333
<span flex></span>
34-
<md-button ng-click="answer('not useful')" style="margin-top:20px;">
34+
<md-button ng-click="answer('not useful')">
3535
Not Useful
3636
</md-button>
37-
<md-button ng-click="answer('useful')" style="margin-top:20px;margin-right:20px;">
37+
<md-button ng-click="answer('useful')" style="margin-right:20px;">
3838
Useful
3939
</md-button>
4040
</div>

src/components/dialog/dialog.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,23 @@ angular.module('material.components.dialog', [
99
.directive('mdDialog', MdDialogDirective)
1010
.provider('$mdDialog', MdDialogProvider);
1111

12-
function MdDialogDirective($$rAF, $mdTheming) {
12+
function MdDialogDirective($$rAF, $mdTheming, $timeout) {
1313
return {
1414
restrict: 'E',
1515
link: function (scope, element, attr) {
1616
$mdTheming(element);
1717
$$rAF(function () {
18+
var images;
1819
var content = element[0].querySelector('md-dialog-content');
19-
if (content && content.scrollHeight >= content.clientHeight) {
20-
element.addClass('md-content-overflow');
20+
21+
if (content) {
22+
images = content.getElementsByTagName('img');
23+
addOverflowClass();
24+
//-- delayed image loading may impact scroll height, check after images are loaded
25+
angular.element(images).on('load', addOverflowClass);
26+
}
27+
function addOverflowClass () {
28+
element.toggleClass('md-content-overflow', content.scrollHeight > content.clientHeight);
2129
}
2230
});
2331
}

0 commit comments

Comments
 (0)