You can just use the sticky css attribute in your scss.

In html or php add class to your component:

<div data-sticky-container class="sticky-container">

and in scss or css:

.sticky-container {
    position: sticky;
    top: 0;
    z-index: 10; 
}

Now just put the distance from top you need!