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..3fa57b54f22259340cbfa7f52f7c942e355872b1 100644 |
| --- a/ui/webui/resources/cr_elements/cr_dialog/cr_dialog.js |
| +++ b/ui/webui/resources/cr_elements/cr_dialog/cr_dialog.js |
| @@ -45,6 +45,8 @@ Polymer({ |
| }, |
| }, |
| + observers: ['onOpenChanged_(open)'], |
|
dpapad
2017/04/13 01:12:12
You probably checked this already, but does this w
scottchen
2017/04/13 20:17:51
It does work, but unfortunately found out that obs
|
| + |
| /** @private {?IntersectionObserver} */ |
| intersectionObserver_: null, |
| @@ -61,9 +63,13 @@ Polymer({ |
| this.addEventListener('keypress', this.onKeypress_.bind(this)); |
| }, |
| - /** @override */ |
| - attached: function() { |
| - if (this.showScrollBorders) { |
| + /** @private */ |
| + onOpenChanged_: function() { |
| + if (!this.showScrollBorders) { |
| + return; |
| + } |
| + |
| + if (this.open !== null && !this.intersectionObserver_) { |
| var bodyContainer = this.$$('.body-container'); |
| var bottomMarker = this.$.bodyBottomMarker; |
| @@ -89,14 +95,10 @@ Polymer({ |
| root: bodyContainer, |
| threshold: 0, |
| })); |
| + |
| this.intersectionObserver_.observe(bottomMarker); |
| this.intersectionObserver_.observe(topMarker); |
| - } |
| - }, |
| - |
| - /** @override */ |
| - detached: function() { |
| - if (this.intersectionObserver_) { |
| + } else if (this.open === null && this.intersectionObserver_) { |
| this.intersectionObserver_.disconnect(); |
| this.intersectionObserver_ = null; |
| } |