simplify pan scroll lock logic and add a few comments