JSFiddle - React, Tailwind, and code Playground

HTML

<div style="position:fixed;  background-color:red; height:100px; width:250px;" id="result"> &nbsp:</div>

<br><br><br><br>

<div class="rightclassname">
<h2>Right Heading1</h2>

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. <div>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.


</div>
	</div>

<div class="clearfix"></div>

<div class="leftclassname">
<h2>Left Heading1</h2>
    

    
<div>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including...

JavaScript

$(document).ready( function() {
	
	var lastScrollTop = 0;
	
	$(window).on('scroll', function(e){
		var st = $(this).scrollTop();
	
			if (st > lastScrollTop){ //down scroll
			
					$(".rightclassname h2").each(function(){
						var moveright = $(this).offset().top 
						if($(window).scrollTop() > moveright && !$(this).hasClass('reached')) {
							$(this).addClass('reached');
							$('#result').html('moveright');
						}
					})
					
					$(".leftclassname h2").each(function(){
						var moveleft = $(this).offset().top ;
						if($(window).scrollTop() > moveleft && !$(this).hasClass('reached'))
						{ 
							$('#result').html('Moveleft');
							$(this).addClass('reached');
						}
					})
			}
			else { //Up scroll
			
					$(".rightclassname h2").each(function(){
						var moveright = $(this).offset().top   ;
						
						if($(window).scrollTop() < moveright && !$(this).hasClass('reached')) {
							$(this).addClass('reached');
							$('#result').html('right up ');
						}
					})
					
					
					$(".leftclassname h2").each(function(){
						var moveleft = $(this).offset().top  ;
						if($(window).scrollTop() < moveleft && !$(this).hasClass('reached'))
						{ 
							$(this).addClass('reached');
							$('#result').html('leftup');
						}
					})
			}
			lastScrollTop = st;	
		})
	})