PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

TouchPan

This event fires when the player moves their finger on the UI element using a touch-enabled device. It fires shortly before GuiObject/TouchSwipe would, and does not fire with GuiObject/TouchTap. This event is useful for allowing the player to manipulate the position of UI elements on the screen.

This event fires with a table of DataType/Vector2 that describe the relative screen positions of the fingers involved in the gesture. In addition, it fires several times with multiple Enum/UserInputStates: Begin after a brief delay, Change when the player moves their finger during the gesture and finally once more with End.

This event cannot be simulated in Studio using the emulator and a mouse; you must have a real touch enabled device to fire this event.

Below is an animation of TouchPan firing on the black semitransparent Frame that covers the screen. The event is being used to manipulate the position of the pink inner Frame. The code for this can be found in the code samples.

TouchPan firing on a real touch-enabled device

See also

  • GuiObject/TouchPinch
  • GuiObject/TouchRotate
  • GuiObject/TouchTap
  • GuiObject/TouchSwipe
  • GuiObject/TouchLongPress

Parameters

Name Type Default Description

A Lua array of DataType/Vector2s, each indicating the position of all the fingers involved in the gesture

Indicates how far the pan gesture has gone from its starting point

Indicates how quickly the gesture is being performed in each dimension

Indicates the Enum/UserInputState of the gesture


Code Samples


Panning UI Element

This code sample is meant to be placed in a LocalScript within an inner Frame that is inside an outer Frame, or other GuiObject. It allows the player to manipulate the position of the inner frame by moving their finger on the outer frame.