Fixed incorrect drag behavior bug.
Split up pan gesture handler into several methods.