function getOffsetTop(self) {
var y = 0;
if(self.offsetParent) while (true) {
y += self.offsetTop;
if(!self.offsetParent) break;
self = self.offsetParent;
}
else if(self.y) y += self.y;
return y;
}
var elem = document.querySelector('.title'),
elemPosTop = getOffsetTop(elem);
window.onscroll = function() {
if((this.scrollTop || document.documentElement.scrollTop) == elemPosTop) {
elem.classList.add('new-class');
this.onscroll = null;
}
}
Как-то так.