Add swipe support for mobile scripts (fix #3989)

Fixes regression caused by #3989.  There are also some formatting fixes that I've noted.
what do you mean "it worked with scripts"