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
 count     - DOM event for number of simultaneous touches
 touchId   - DOM touch event identifier
 event     - Original DOM event
 dt        - Time since last update

Constructor

Inputs.TouchInput

(
  • [options]
)

Parameters:

  • [options] Object optional

    Options

    • [scale=1] Number optional

      Scale the response to the mouse

    • [track=1] Number optional

      Max simultaneous touches to record

    • [limit=Infinity] Number optional

      Limit number of touches. If reached, no events are emitted

    • [direction] Number optional

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

    • [rails=false] Boolean optional

      If a direction is unspecified, movement in the orthogonal to the principal direction is suppressed

Example:

 var touchInput = new TouchInput({
             direction : TouchInput.DIRECTION.Y
         });
        
         touchInput.subscribe(surface);
        
         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);
         });

Item Index

Methods

Properties

Methods

filter

(
  • filterFn
)
SimpleStream

Inherited from Streams.SimpleStream:

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

Parameters:

  • filterFn Function
    Function to filter event payload

Returns:

SimpleStream: stream Filtered stream

map

(
  • mapperFn
)
SimpleStream

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

Returns:

SimpleStream: stream Mapped stream

pluck

(
  • key
)
SimpleStream

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 object.

Parameters:

Returns:

SimpleStream: stream Plucked stream

split

(
  • splitterFn
)

Inherited from Streams.SimpleStream:

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

Parameters:

Properties

DIRECTION

Object static

Constrain the input along a specific axis.

Sub-properties: