Show:

Detects two-finger pinching motion and emits start, update and end events with the payload data:

 value         - Distance between the two touches
 delta         - Differential in successive distances
 velocity      - Relative velocity between two touches
 displacement  - Total accumulated displacement
 center        - Midpoint between the two touches
 touchIds       - Array of DOM event touch identifiers

Note: Unlike PinchInput, which produces pixel values of displacement between two touches, ScaleInput produces dimensionless values corresponding to scaling of the initial distance between the touches. For example, if two touches begin at 100 px apart, and move to 200 px apart, ScaleInput will emit a value of 2 (for 2x magnification), while PinchInput will emit a value of 100.

Constructor

Inputs.ScaleInput

(
  • options
)

Parameters:

  • options Object

    Options

    • [scale=1] Number optional

      Scale the response to pinch

Example:

 var scaleInput = new ScaleInput();
        
         scaleInput.subscribe(Engine) // listens on window events
        
         scaleInput.on('start', function(payload){
             console.log('start', payload);
         });
        
         scaleInput.on('update', function(payload){
             console.log('update', payload);
         });
        
         scaleInput.on('end', function(payload){
             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: