Show:

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:

  • [options] Object optional

    Options

    • [direction] Number optional

      Direction to project movement onto. Options found in TouchInput.DIRECTION.

    • [scale=1] Number optional

      Scale the response to the mouse

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
)

Inherited from Core.OptionsManager:

Adds a handler to the type channel which will be executed on emit.

Parameters:

filter

(
  • filterFn
)

Inherited from Streams.SimpleStream:

Filter converts the current stream into a new stream that only emits if the filter condition is satisfied. The function should return a Boolean.

Parameters:

  • filterFn Function
    Function to filter event payload

get

(
  • key
)
Object

Inherited from Core.OptionsManager:

Look up options value by key or get the full options hash.

Parameters:

Returns:

Object:

Associated object or full options hash

getOptions

()

Inherited from Core.OptionsManager:

Alias for get

key

(
  • key
)
OptionsManager

Inherited from Core.OptionsManager:

Return OptionsManager based on sub-object retrieved by key.

Parameters:

Returns:

OptionsManager:

Value

map

(
  • mapperFn
)

Inherited from Streams.SimpleStream:

Map converts the current stream into a new stream with a modified (mapped) data payload.

Parameters:

  • mapperFn Function
    Function to map event payload

off

(
  • type
  • handler
)

Inherited from Core.OptionsManager:

Removes the handler from the type channel. This undoes the work of on.

Parameters:

OptionsManager.patch

(
  • options
  • patch
)
Object

Inherited from Core.OptionsManager but overwritten in

Constructor method. Create OptionsManager from source dictionary with arguments overriden by patch dictionary.

Parameters:

  • options Object

    Options to be patched

  • patch ...Object

    Options to overwrite

Returns:

Object:

source

patch

(
  • options
)
OptionsManager

Inherited from Core.OptionsManager:

Patch options with provided patches. Triggers change event on the object.

Parameters:

  • options Object

    Patch options

Returns:

OptionsManager:

this

pluck

(
  • key
)

Inherited from Streams.SimpleStream:

Pluck is an opinionated mapper. It projects a Stream onto one of its return values. Useful if a Stream returns an array or an object.

Parameters:

set

(
  • key
  • value
)
OptionsManager

Inherited from Core.OptionsManager:

Set key to value. Outputs change event if a value is overwritten.

Parameters:

Returns:

OptionsManager:

Updated OptionsManager

setOptions

()

Inherited from Core.OptionsManager:

Alias for patch

split

(
  • splitterFn
)

Inherited from Streams.SimpleStream:

Split maps one of several streams based on custom logic. The function should return an EventEmitter.

Parameters:

track

(
  • data
)
private

Inherited from Inputs.TouchTracker:

Record touch data, if selective is false.

Parameters:

Properties

DIRECTION

Object static

Constrain the input along a specific axis.

Sub-properties: