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

Side by Side Diff: ui/file_manager/audio_player/elements/track_list.js

Issue 1510453002: AudioPlayer: Fix the way to find a track element with given index. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 | « no previous file | 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 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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698