Chromium Code Reviews| Index: ui/webui/resources/cr_elements/cr_dialog/cr_dialog.js |
| diff --git a/ui/webui/resources/cr_elements/cr_dialog/cr_dialog.js b/ui/webui/resources/cr_elements/cr_dialog/cr_dialog.js |
| index c98c75ac4053eda397cdc7758103f9edb91fd87d..a1fdd7386168484f5bd81d91ff0839be8b50e0fc 100644 |
| --- a/ui/webui/resources/cr_elements/cr_dialog/cr_dialog.js |
| +++ b/ui/webui/resources/cr_elements/cr_dialog/cr_dialog.js |
| @@ -48,6 +48,9 @@ Polymer({ |
| /** @private {?IntersectionObserver} */ |
| intersectionObserver_: null, |
| + /** @private {?MutationObserver} */ |
| + mutationObserver_: null, |
| + |
| /** @override */ |
| ready: function() { |
| // If the active history entry changes (i.e. user clicks back button), |
| @@ -64,6 +67,33 @@ Polymer({ |
| /** @override */ |
| attached: function() { |
| if (this.showScrollBorders) { |
| + this.mutationObserver_ = new MutationObserver(function() { |
| + if (this.open) { |
| + this.addIntersectionObserver_(); |
| + } else { |
| + this.removeIntersectionObserver_(); |
| + } |
| + }.bind(this)); |
| + |
| + this.mutationObserver_.observe(this, { |
| + attributes: true, |
| + attributeFilter: ['open'], |
| + }); |
| + } |
| + }, |
| + |
| + /** @override */ |
| + detached: function() { |
| + this.removeIntersectionObserver_(); |
| + if (this.mutationObserver_) { |
| + this.mutationObserver_.disconnect(); |
| + this.mutationObserver_ = null; |
| + } |
| + }, |
| + |
| + /** @private */ |
| + addIntersectionObserver_: function() { |
|
dpapad
2017/04/13 22:02:03
Nit: You can reduce indentation throughout this me
scottchen
2017/04/13 22:33:29
Done.
|
| + if (!this.intersectionObserver_) { |
| var bodyContainer = this.$$('.body-container'); |
| var bottomMarker = this.$.bodyBottomMarker; |
| @@ -94,8 +124,8 @@ Polymer({ |
| } |
| }, |
| - /** @override */ |
| - detached: function() { |
| + /** @private */ |
| + removeIntersectionObserver_: function() { |
| if (this.intersectionObserver_) { |
| this.intersectionObserver_.disconnect(); |
| this.intersectionObserver_ = null; |