This version is old school.
Please find jQuery plugins on npm.
jQuery Lock Fixed
by Yvo Schaap
jQuery plugin which allows for DOM elements to be positioned anywhere on the page, and lock within the user's viewport when scrolling. Common use case is a menu under a header, which on scrolling stays fixed within the viewport.