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

Unified Diff: third_party/polymer/v1_0/components-chromium/app-layout/app-scrollpos-control/app-scrollpos-control-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-scrollpos-control/app-scrollpos-control-extracted.js
diff --git a/third_party/polymer/v1_0/components-chromium/app-layout/app-scrollpos-control/app-scrollpos-control-extracted.js b/third_party/polymer/v1_0/components-chromium/app-layout/app-scrollpos-control/app-scrollpos-control-extracted.js
new file mode 100644
index 0000000000000000000000000000000000000000..7b38c2d2b6f4aa8cdeb26f74c1514d1c86be1004
--- /dev/null
+++ b/third_party/polymer/v1_0/components-chromium/app-layout/app-scrollpos-control/app-scrollpos-control-extracted.js
@@ -0,0 +1,54 @@
+Polymer({
+ is: 'app-scrollpos-control',
+
+ properties: {
+ /**
+ * The selected page.
+ */
+ selected: {
+ type: String,
+ observer: '_selectedChanged'
+ },
+
+ /**
+ * Reset the scroll position to 0.
+ */
+ reset: {
+ type: Boolean,
+ value: false
+ }
+ },
+
+ observers: [
+ '_updateScrollPos(selected, reset)'
+ ],
+
+ created: function() {
+ this._scrollposMap = {};
+ },
+
+ _selectedChanged: function(selected, old) {
+ if (old != null) {
+ this._scrollposMap[old] = {x: window.pageXOffset, y: window.pageYOffset};
+ }
+ },
+
+ _updateScrollPos: function(selected, reset) {
+ this.debounce('_updateScrollPos', function() {
+ var pos = this._scrollposMap[this.selected];
+ if (pos != null && !this.reset) {
+ this._scrollTo(pos.x, pos.y);
+ } else {
+ this._scrollTo(0, 0);
+ }
+ });
+ },
+
+ _scrollTo: function(x, y) {
+ Polymer.AppLayout.scroll({
+ left: x,
+ top: y,
+ behavior: 'silent'
+ });
+ }
+ });

Powered by Google App Engine
This is Rietveld 408576698