fix pan gesture bug and add some comments