JSFiddle - React, Tailwind, and code Playground

HTML

<div class="container">
  <div class="col-left">
    <div class="sidebar">
      fixed sidebar
    </div>
  </div>

  <div class="col-right">
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>
    <p>Paragraph</p>

  </div>
</div>

<footer>Footer</footer>

CSS

.container {
  outline: 1px solid red;
  position: relative;
}

.col-left {
  width: 58%;
  display: inline-block;
  outline: 1px solid black;
  vertical-align: top;
  height: 100%;
}

.col-right {
  width: 40%;
  display: inline-block;
  outline: 1px solid black;
  vertical-align: top;
}

.sidebar {
  position: fixed;
  top: 50px;
  left: 50px;
  height: 200px;
  width: 100px;
  background: #fff;
}

footer {
  background: #000;
  width: 100%;
  height: 300px;
  margin-top: 100px;
  color: #fff;
}

JavaScript

jQuery(window).scroll(function(){
  var scrollBottom = jQuery(document).height() - jQuery(this).scrollTop() - jQuery(this).height();
  console.log(scrollBottom);
  
  	 if (scrollBottom < 300){
  		 jQuery('.sidebar').css('bottom', Math.abs(scrollBottom - 420));
       jQuery('.sidebar').css('top', 'auto');
     } else {
       jQuery('.sidebar').css('bottom', 'auto');
       jQuery('.sidebar').css('top', '50px');
     }
});