Skip to content

Commit

Permalink
Scroll navigation pane automatically on view activation
Browse files Browse the repository at this point in the history
In case there are enough playlists to make the navigation pane scrollable, the
link to the activated view may be off the view port. In such occasions, the
navigation pane is now scrolled automatically upon view activation to make the
link of the activated view visible. This is useful mostly when the view
activation happens as response to some other action than clicking the
navigation pane link (say, creating a new playlist or clicking the playing
song name on the controls pane to jump to the playing view).

refs owncloud#1083
  • Loading branch information
paulijar committed Aug 26, 2023
1 parent a95071d commit eef55d4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions js/app/controllers/navigationcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,17 @@ angular.module('Music').controller('NavigationController', [
$scope.togglePlay($rootScope.currentView, playlist);
}
}
// ensure that the link to the current view is visible in the navigation pane,
// in case there are so many playlists that the navigation pane is scrollable
$timeout(() => {
const navPaneContent = $('#app-navigation ul');
const navItem = navPaneContent.find('.music-navigation-item.active');
const navItemTop = navItem.offset().top - $('#header').height();
const navItemBottom = navItemTop + navItem.height();
if (navItemTop < 0 || navItemBottom > navPaneContent.innerHeight()) {
navPaneContent.scrollToElement(navItem, 0, 300);
}
});
});
}
]);

0 comments on commit eef55d4

Please sign in to comment.