themefisher / sleek-bootstrap

Sleek Dashboard - Free Bootstrap Admin Template and UI Kit
https://themefisher.com/products/sleek
MIT License
889 stars 186 forks source link

Initial scroll #272

Closed sama55 closed 4 years ago

sama55 commented 4 years ago

Now, no matter what page is displayed, sidebar is shown from the top. Can I show selected menu at the top?

sama55 commented 4 years ago

I solved this in the following method. First, when generating sidebar HTML, add ID(e.g. #slimscrollstart) to the selected menu. Second: I added following Javascript.

$(document).ready(function(){ // Customize SlimScroll if($('#slimscrollstart').length != 0) { var sidebar_rect = $(".sidebar-scrollbar").get(0).getBoundingClientRect(); var target_rect = $('#slimscrollstart').get(0).getBoundingClientRect(); var scroll_position = target_rect.top - sidebar_rect.top - 10; $(".sidebar-scrollbar").slimScroll({ scrollTo : scroll_position + 'px' }); } });