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

Side by Side Diff: chrome/browser/resources/md_history/history_list.js

Issue 2644733003: MD History: Scroll history-items into view when their action menu is opened (Closed)
Patch Set: Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/resources/md_history/app.crisper.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 Polymer({ 5 Polymer({
6 is: 'history-list', 6 is: 'history-list',
7 7
8 behaviors: [HistoryListBehavior], 8 behaviors: [HistoryListBehavior],
9 9
10 properties: { 10 properties: {
(...skipping 11 matching lines...) Expand all
22 // An array of history entries in reverse chronological order. 22 // An array of history entries in reverse chronological order.
23 historyData_: Array, 23 historyData_: Array,
24 24
25 lastFocused_: Object, 25 lastFocused_: Object,
26 26
27 querying: Boolean, 27 querying: Boolean,
28 }, 28 },
29 29
30 listeners: { 30 listeners: {
31 'remove-bookmark-stars': 'removeBookmarkStars_', 31 'remove-bookmark-stars': 'removeBookmarkStars_',
32 'open-menu': 'onOpenMenu_',
32 }, 33 },
33 34
34 /** @override */ 35 /** @override */
35 attached: function() { 36 attached: function() {
36 // It is possible (eg, when middle clicking the reload button) for all other 37 // It is possible (eg, when middle clicking the reload button) for all other
37 // resize events to fire before the list is attached and can be measured. 38 // resize events to fire before the list is attached and can be measured.
38 // Adding another resize here ensures it will get sized correctly. 39 // Adding another resize here ensures it will get sized correctly.
39 /** @type {IronListElement} */ (this.$['infinite-list']).notifyResize(); 40 /** @type {IronListElement} */ (this.$['infinite-list']).notifyResize();
40 this.$['infinite-list'].scrollTarget = this; 41 this.$['infinite-list'].scrollTarget = this;
41 this.$['scroll-threshold'].scrollTarget = this; 42 this.$['scroll-threshold'].scrollTarget = this;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 * @private 99 * @private
99 */ 100 */
100 loadMoreData_: function() { 101 loadMoreData_: function() {
101 if (this.resultLoadingDisabled_ || this.querying) 102 if (this.resultLoadingDisabled_ || this.querying)
102 return; 103 return;
103 104
104 this.fire('load-more-history'); 105 this.fire('load-more-history');
105 }, 106 },
106 107
107 /** 108 /**
109 * Ensure that the item is visible in the scroll pane when its menu is
110 * opened (it is possible to open off-screen items using keyboard shortcuts).
111 * @param {Event} e
112 * @private
113 */
114 onOpenMenu_: function(e) {
115 var index = e.detail.index;
116 var list = /** @type {IronListElement} */ (this.$['infinite-list']);
117 if (index < list.firstVisibleIndex || index > list.lastVisibleIndex)
118 list.scrollToIndex(index);
119 },
120
121 /**
108 * Check whether the time difference between the given history item and the 122 * Check whether the time difference between the given history item and the
109 * next one is large enough for a spacer to be required. 123 * next one is large enough for a spacer to be required.
110 * @param {HistoryEntry} item 124 * @param {HistoryEntry} item
111 * @param {number} index The index of |item| in |historyData_|. 125 * @param {number} index The index of |item| in |historyData_|.
112 * @param {number} length The length of |historyData_|. 126 * @param {number} length The length of |historyData_|.
113 * @return {boolean} Whether or not time gap separator is required. 127 * @return {boolean} Whether or not time gap separator is required.
114 * @private 128 * @private
115 */ 129 */
116 needsTimeGap_: function(item, index, length) { 130 needsTimeGap_: function(item, index, length) {
117 return md_history.HistoryItem.needsTimeGap( 131 return md_history.HistoryItem.needsTimeGap(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 166
153 /** 167 /**
154 * @param {number} index 168 * @param {number} index
155 * @return {string} 169 * @return {string}
156 * @private 170 * @private
157 */ 171 */
158 pathForItem_: function(index) { 172 pathForItem_: function(index) {
159 return 'historyData_.' + index; 173 return 'historyData_.' + index;
160 }, 174 },
161 }); 175 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_history/app.crisper.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698