The main functionality works, but now I need to make the controller list smaller, so that it fits better to the screen, as it's fixed positioned.
So, I think it should show next three list-items from active item and 2 previous ones.
Something like this would work, but I think there should be shorter and more convinient way:
//Display closest items $('#historyController li.active').prevAll('li:not(.first)').hide().slice(0,2).show(); $('#historyController li.active').nextAll('li:not(.last)').hide().slice(0,3).show();
Any tips for re-factoring current code for better performance would be helpful as well.