How do I create a sticky navigation bar in Open Social?
Seems like you're over-complicating it by re-writing things that bootstrap already does.  The stock bootstrap theme and most of it's subthemes should have a setting in the theme for setting a fixed nav bar.  

See Appearances -> Theme settings -> Components -> Navbar.  There is an option for fixed top navbar.

If that does not do what you want, there is also the Bootstrap Affix plug-in which should be part of the standard drupal bootstrap theme.  

See:  This W3school page for details.