Change div background when div is scrolled (no height)

I should have a <div> change the background-color when it reaches the middle of the screen, but I cannot use the window height (jQuery(window).scrollTop();) because the size of the contents above the div is not known or is variable.

I started with this code, but I don’t know how to change the setting from “scroll from top” to “scroll/position of the div”: https://jsfiddle.net/cLo2t6kn/1/