JSFiddle - React, Tailwind, and code Playground

HTML

<div id="ids"></div>

CSS

.red{
    background: red;
}

body{
        transition: all 1s;
}

#ids{
    width: 200px;
    height: 200px;
    margin: 2000px 0;
    background: tomato;
}

JavaScript

$(document).scroll(function(){
  var what = $("#ids").offset().top, 
        pos = $(window).height() + $(window).scrollTop()
  $("body").toggleClass("red", what <= pos);
});