copying scroll normalization from http://jsfiddle.net/SimoneGianni/pXzVv/