Inputs.TouchInput Class
samsara/inputs/TouchInput.js:19
Wrapper for DOM touch events. Converts
touchstart
-> start
touchmove
-> update
touchend
-> end
TouchInput emits these events with the following payload data:
value
- Displacement in pixels from touchstart
delta
- Differential in pixels between successive mouse positions
velocity
- Velocity of mouse movement in pixels per second
cumulate
- Accumulated displacement over successive displacements
clientX
- DOM event clientX property
clientY
- DOM event clientY property
count
- DOM event for number of simultaneous touches
touchId
- DOM touch event identifier
Constructor
Inputs.TouchInput
-
[options]
Parameters:
Example:
var touchInput = new TouchInput({
direction : TouchInput.DIRECTION.Y
});
touchInput.subscribe(Engine);
touchInput.on('start', function(payload){
// fired on mouse down
console.log('start', payload);
});
touchInput.on('update', function(payload){
// fired on mouse move
console.log('update', payload);
});
touchInput.on('end', function(payload){
// fired on mouse up
console.log('end', payload);
});
Methods
"on"
-
type
-
handler
Adds a handler to the type
channel which will be executed on emit
.
filter
-
filterFn
Parameters:
-
filterFn
FunctionFunction to filter event payload
get
-
key
Look up options value by key or get the full options hash.
Parameters:
-
key
StringKey
Returns:
Associated object or full options hash
getOptions
()
Alias for get
key
-
key
Return OptionsManager based on sub-object retrieved by key
.
Parameters:
-
key
StringKey
Returns:
Value
map
-
mapperFn
Parameters:
-
mapperFn
FunctionFunction to map event payload
off
-
type
-
handler
Removes the handler
from the type
channel.
This undoes the work of on
.
OptionsManager.patch
-
options
-
patch
Constructor method. Create OptionsManager from source dictionary with arguments overriden by patch dictionary.
Parameters:
-
options
ObjectOptions to be patched
-
patch
...ObjectOptions to overwrite
Returns:
source
patch
-
options
Patch options with provided patches. Triggers change
event on the object.
Parameters:
-
options
ObjectPatch options
Returns:
this
pluck
-
key
set
-
key
-
value
Set key to value. Outputs change
event if a value is overwritten.
Returns:
Updated OptionsManager
setOptions
()
Alias for patch
split
-
splitterFn
Parameters:
-
splitterFn
FunctionSplitter function