fix scroll offset calculation

Fix for issue #12