Pan/zoom code (not working in both directions)