OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** | 5 /** |
6 * @typedef {?{ | 6 * @typedef {?{ |
7 * url: string, | 7 * url: string, |
8 * title: string, | 8 * title: string, |
9 * artist: string, | 9 * artist: string, |
10 * artwork: Object, | 10 * artwork: Object, |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 onWindowResize_: function() { | 184 onWindowResize_: function() { |
185 this.ensureTrackInViewport_(this.currentTrackIndex); | 185 this.ensureTrackInViewport_(this.currentTrackIndex); |
186 }, | 186 }, |
187 | 187 |
188 /** | 188 /** |
189 * Scrolls the track list to ensure the given track in the viewport. | 189 * Scrolls the track list to ensure the given track in the viewport. |
190 * @param {number} trackIndex The index of the track to be in the viewport. | 190 * @param {number} trackIndex The index of the track to be in the viewport. |
191 * @private | 191 * @private |
192 */ | 192 */ |
193 ensureTrackInViewport_: function(trackIndex) { | 193 ensureTrackInViewport_: function(trackIndex) { |
194 var trackSelector = '::shadow .track[index="' + trackIndex + '"]'; | 194 var trackElement = this.$$('.track[index="' + trackIndex + '"]'); |
195 var trackElement = this.querySelector(trackSelector); | |
196 if (trackElement) { | 195 if (trackElement) { |
197 var viewTop = this.scrollTop; | 196 var viewTop = this.scrollTop; |
198 var viewHeight = this.clientHeight; | 197 var viewHeight = this.clientHeight; |
199 var elementTop = trackElement.offsetTop; | 198 var elementTop = trackElement.offsetTop; |
200 var elementHeight = trackElement.offsetHeight; | 199 var elementHeight = trackElement.offsetHeight; |
201 | 200 |
202 if (elementTop < viewTop) { | 201 if (elementTop < viewTop) { |
203 // Adjust the tops. | 202 // Adjust the tops. |
204 this.scrollTop = elementTop; | 203 this.scrollTop = elementTop; |
205 } else if (elementTop + elementHeight <= viewTop + viewHeight) { | 204 } else if (elementTop + elementHeight <= viewTop + viewHeight) { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 | 327 |
329 var newTrackIndex = this.playOrder[newPlayOrder]; | 328 var newTrackIndex = this.playOrder[newPlayOrder]; |
330 console.assert( | 329 console.assert( |
331 (0 <= newTrackIndex && newTrackIndex < this.tracks.length), | 330 (0 <= newTrackIndex && newTrackIndex < this.tracks.length), |
332 'Insufficient TrackList.playOrder. New Play Order: ' + newPlayOrder); | 331 'Insufficient TrackList.playOrder. New Play Order: ' + newPlayOrder); |
333 | 332 |
334 return newTrackIndex; | 333 return newTrackIndex; |
335 }, | 334 }, |
336 }); | 335 }); |
337 })(); // Anonymous closure | 336 })(); // Anonymous closure |
OLD | NEW |