Ignore trailing junk when scrolling past end

To avoid performance hit, content size update is noew performed
only when scrolling past end is enabled. Some refactoring are
done to reuse parts of existing calculation.