var targetElem = $('.elem');
var targetElemPos = targetElem.offset().top;
$(window).resize(function(){
targetElemPos = targetElem.offset().top;
});
$(window).scroll(function(){
var scrolledAtop = $(this).scrollTop();
if(scrolledAtop > targetElemPos){
targetElem.addClass('elem-active');
}
});