Skip to main content

TouchDataProvider

Class

This provider is returned by global.touchSystem and allows your lens to handle any touches on the screen, and optionally let certain touch types to pass thro…

  • Available on all platforms
Platform details: Snapchat, SPECS, Camera Kit Web, Camera Kit Mobile fully supported.

Platform details

  • Snapchat — Fully supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Fully supported.

  • Camera Kit Mobile — Fully supported.

This provider is returned by global.touchSystem and allows your lens to handle any touches on the screen, and optionally let certain touch types to pass through (let Snapchat handle the touch).

Possible TouchType exception values:

  • "TouchTypeNone"
  • "TouchTypeTouch"
  • "TouchTypeTap"
  • "TouchTypeDoubleTap"
  • "TouchTypeScale"
  • "TouchTypePan"
  • "TouchTypeSwipe"

Index

Example

// Enable full screen touches
global.touchSystem.touchBlocking = true;

// Allow double-tap to be passed through to Snapchat to flip the camera.
global.touchSystem.enableTouchBlockingException("TouchTypeDoubleTap", true);

// Or alternatively enable "TouchTypeDoubleTap" using mask
var mask = global.touchSystem.touchBlockingExceptionMask;
mask = global.touchSystem.composeTouchBlockingExceptionMask(mask, "TouchTypeDoubleTap");
global.touchSystem.touchBlockingExceptionMask = mask;

Extends

Properties

touchBlocking

touchBlocking: boolean

Set your lens to handle touches on the screen, preventing default Snapchat touch behavior from occuring. Useful for enabling full screen touches without any touch components. It is similar to creating a plane the size of the screen in front of the camera.

Default Value

false

touchBlockingExceptionMask

touchBlockingExceptionMask: number

The current touch mask.

Default Value

0

Methods

composeTouchBlockingExceptionMask()

composeTouchBlockingExceptionMask(currentMask, newException): number

Returns a copy of currentMask with the newException flag set to true.

Parameters

ParameterType
currentMasknumber
newExceptionstring

Returns

number


enableTouchBlockingException()

enableTouchBlockingException(exception, enable): void

Allow or stop allowing a certain TouchType to pass through your lens. Useful for allowing Snapchat to handle certain TouchType, e.g. allowing TouchTypeDoubleTap to flip the camera.

Parameters

ParameterType
exceptionstring
enableboolean

Returns

void


getTypeName()

static getTypeName(): TypeName<TouchDataProvider>

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<TouchDataProvider>

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


isSame()

isSame(other): boolean

Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame