Fixed bugs with pan gesture.