Skip to content

Commit 838d3e9

Browse files
committed
Jump display to current song #499
1 parent 22329bd commit 838d3e9

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

js/app.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,16 @@ OCA.Audioplayer.Core = {
125125

126126
selectCategoryItemFromPreset: function () {
127127
if (OCA.Audioplayer.Core.CategorySelectors[1]) {
128-
document.querySelector('#myCategory li[data-id="' + OCA.Audioplayer.Core.CategorySelectors[1] + '"]').classList.add('active');
129-
var appNavigation = $('#app-navigation');
130-
appNavigation.scrollTop(appNavigation.scrollTop() + $('#myCategory li.active').first().position().top - 25);
128+
let activeItem = document.querySelector('#myCategory li[data-id="' + OCA.Audioplayer.Core.CategorySelectors[1] + '"]');
129+
activeItem.classList.add('active');
130+
activeItem.scrollIntoView({behavior: 'smooth', block: 'center',});
131+
131132
OCA.Audioplayer.Category.handleCategoryClicked(null, function () { // select the last played title
132133
if (OCA.Audioplayer.Core.CategorySelectors[2]) {
133134
var item = $('#individual-playlist li[data-trackid="' + OCA.Audioplayer.Core.CategorySelectors[2] + '"]');
134135
item.find('.icon').hide();
135136
item.find('.ioc').removeClass('ioc-volume-up').addClass('ioc-volume-off').show();
137+
document.querySelector('#individual-playlist li[data-trackid="' + OCA.Audioplayer.Core.CategorySelectors[2] + '"]').scrollIntoView({behavior: 'smooth', block: 'center',});
136138
if (OCA.Audioplayer.Core.CategorySelectors[3]) {
137139
// if the title was previously played, the last position will be set
138140
OCA.Audioplayer.Player.trackStartPosition = OCA.Audioplayer.Core.CategorySelectors[3];
@@ -753,6 +755,10 @@ OCA.Audioplayer.UI = {
753755

754756
document.getElementById('nowPlayingText').innerHTML = iocIcon[OCA.Audioplayer.Player.currentTrackIndex].parentElement.parentElement.dataset.title;
755757
document.querySelectorAll('.albumwrapper li')[OCA.Audioplayer.Player.currentTrackIndex].classList.add('isActive');
758+
759+
document.querySelectorAll('.albumwrapper li')[OCA.Audioplayer.Player.currentTrackIndex].scrollIntoView(
760+
{behavior: 'smooth',
761+
block: 'center',});
756762
}
757763

758764
//in every case, update the playbar and medaservices

0 commit comments

Comments
 (0)