Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: third_party/polymer/v1_0/components-chromium/app-layout/app-box/app-box-extracted.js

Issue 1984963002: Roll Polymer elements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/v1_0/components-chromium/app-layout/app-box/app-box-extracted.js
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-box/app-box-extracted.js b/third_party/polymer/v1_0/components-chromium/app-layout/app-box/app-box-extracted.js
new file mode 100644
index 0000000000000000000000000000000000000000..674db91f491c745d27975539085a73475a5a6417
--- /dev/null
+++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-box/app-box-extracted.js
@@ -0,0 +1,93 @@
+Polymer({
+ is: 'app-box',
+
+ behaviors: [
+ Polymer.AppScrollEffectsBehavior,
+ Polymer.IronResizableBehavior
+ ],
+
+ listeners: {
+ 'iron-resize': '_resizeHandler'
+ },
+
+ /**
+ * The current scroll progress.
+ *
+ * @type {number}
+ */
+ _progress: 0,
+
+ attached: function() {
+ this.resetLayout();
+ },
+
+ /**
+ * Resets the layout. This method is automatically called when the element is attached to the DOM.
+ *
+ * @method resetLayout
+ */
+ resetLayout: function() {
+ this.debounce('_resetLayout', function() {
+ // noop if the box isn't in the rendered tree
+ if (this.offsetWidth === 0 && this.offsetHeight === 0) {
+ return;
+ }
+
+ var scrollTop = this._clampedScrollTop;
+ var savedDisabled = this.disabled;
+
+ this.disabled = true;
+ this._elementTop = this._getElementTop();
+ this._elementHeight = this.offsetHeight;
+ this._cachedScrollTargetHeight = this._scrollTargetHeight;
+ this._setUpEffect();
+ this._updateScrollState(scrollTop);
+ this.disabled = savedDisabled;
+ }, 1);
+ },
+
+ _getElementTop: function() {
+ var currentNode = this;
+ var top = 0;
+
+ while (currentNode && currentNode !== this.scrollTarget) {
+ top += currentNode.offsetTop;
+ currentNode = currentNode.offsetParent;
+ }
+ return top;
+ },
+
+ _updateScrollState: function(scrollTop) {
+ if (this.isOnScreen()) {
+ var viewportTop = this._elementTop - scrollTop;
+ this._progress = 1 - (viewportTop + this._elementHeight) / this._cachedScrollTargetHeight;
+ this._runEffects(this._progress, scrollTop);
+ }
+ },
+
+ /**
+ * Returns true if this app-box is on the screen.
+ * That is, visible in the current viewport.
+ *
+ * @method isOnScreen
+ * @return {boolean}
+ */
+ isOnScreen: function() {
+ return this._elementTop < this._scrollTop + this._cachedScrollTargetHeight
+ && this._elementTop + this._elementHeight > this._scrollTop;
+ },
+
+ _resizeHandler: function() {
+ this.resetLayout();
+ },
+
+ /**
+ * Returns an object containing the progress value of the scroll effects.
+ *
+ * @method getScrollState
+ * @return {Object}
+ */
+ getScrollState: function() {
+ return { progress: this._progress };
+ }
+ });

Powered by Google App Engine
This is Rietveld 408576698