But if orientation changes before you've scrolled, you'll get an error (undefined divided by undefined or something) in setOffsetPosition.  Maybe you just need to make setOffsetPosition return early if the variables are undefined.