Sidebar js refactor

Refactor logic, lots of animation fixes