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 d15ed9b8173a769d12afe886806d1509a99cfffc..9d90625ee4b0b7d1de2f57df33d5f9db367bbe08 100644 |
--- a/ui/webui/resources/cr_elements/cr_dialog/cr_dialog.js |
+++ b/ui/webui/resources/cr_elements/cr_dialog/cr_dialog.js |
@@ -29,8 +29,17 @@ Polymer({ |
type: Boolean, |
value: false, |
}, |
+ |
+ showScrollBorders: { |
+ type: Boolean, |
+ value: false, |
+ reflectToAttribute: true, |
+ }, |
}, |
+ /** @private {?IntersectionObserver} */ |
+ intersectionObserver_: null, |
+ |
/** @override */ |
ready: function() { |
// If the active history entry changes (i.e. user clicks back button), |
@@ -41,6 +50,34 @@ Polymer({ |
}.bind(this)); |
}, |
+ /** @override */ |
+ attached: function() { |
+ if (this.showScrollBorders) { |
+ var bodyContainer = this.$$('.body-container'); |
+ |
+ var callback = function(entries) { |
+ assert(entries.length == 1); |
+ entries[0].intersectionRatio == 0 ? |
dpapad
2017/03/30 18:25:00
Can you simplify this, similar to https://coderevi
scottchen
2017/03/30 19:24:34
Done.
|
+ bodyContainer.classList.add('bottom-scrollable') : |
+ bodyContainer.classList.remove('bottom-scrollable'); |
+ }; |
+ |
+ this.intersectionObserver_ = new IntersectionObserver(callback, { |
+ root: bodyContainer, |
+ threshold: 0, |
+ }); |
+ this.intersectionObserver_.observe(this.$.bodyBottomMarker); |
+ } |
+ }, |
+ |
+ /** @override */ |
+ detached: function() { |
+ if (this.intersectionObserver_) { |
+ this.intersectionObserver_.disconnect(); |
+ this.intersectionObserver_ = null; |
+ } |
+ }, |
+ |
cancel: function() { |
this.fire('cancel'); |
HTMLDialogElement.prototype.close.call(this, ''); |