Reader(options)

new Reader(options)

To find out it's flick or click or nothing from event datas.

Parameters:
Name Type Description
options object
Properties
Name Type Attributes Default Description
type string

'flick', 'longtab', 'dblclick'

clickTerm number <optional>

(DoubleClick) Available time distance between first and second click event.

maxDist number <optional>

(DoubleClick) Available movement distance

flickTime number <optional>

(Flick) If in this time, do not check move distance

flickRange number <optional>

(Flick) If not in time, compare move distance with flick ragne.

longTabTerm number <optional>

(LongTab) Term for checking longtab

minDist number <optional>

(Flick, LongTab) Minimum distance for check available movement.

usageStatistics boolean <optional>
true

Let us know the hostname. If you don't want to send the hostname, please set to false.

Example
var GestureReader = tui.GestureReader; // or require('tui-gesture-reader');
var instance = new GestureReader({
     type: 'flick'
});

Methods

figure(eventData) → {object}

Pick event type from eventData

Parameters:
Name Type Description
eventData object

Event data

Returns:
object -

Info of direction and flicking state

Example
instance.figure({
     list : [{x: 0, y: 0}, {x: 100, y: 100}],
     start: 0,
     end: 50
});
=> {
     direction: 'SE',
     isFlick: false
}

getCardinalPoints(first, last) → {string}

Return cardinal points figured out

Parameters:
Name Type Description
first object

Start point

last object

End point

Returns:
string -

Direction info

Example
instance.getDirection({x: 0, y: 0}, {x: 100, y: 100});
=> 'SE';

getCloseCardinal(first, last, cardinalPoint) → {string}

Return nearest four cardinal points

Parameters:
Name Type Description
first object

Start point

last object

End point

cardinalPoint string

CardinalPoint from getCardinalPoints

Returns:
string
Example
instance.getDirection({x: 0, y: 50}, {x: 100, y: 100});
=> 'W';

getDirection(list) → {string}

Return direction figured out

Parameters:
Name Type Description
list array

eventPoint list

Returns:
string
Example
instance.getDirection([{x: 0, y: 0}, {x: 100, y: 100}]);
=> 'SE';

isAvailableZone(pos) → {boolean}

Compare with saved position to safe zone

Parameters:
Name Type Description
pos object

Position to compare with saved position

Returns:
boolean -

State of available zone

Example
instance.isAvailableZone({
     x: 10,
     y: 10
});

isDoubleClick(pos) → {*}

Check click or double click

Parameters:
Name Type Description
pos object

Distance from mousedown/touchstart to mouseup/touchend

Returns:
*
Example
instance.isDoubleClick({
     x: 10,
     y: 10
});

isFlick(eventData) → {string}

Extract type of event

Parameters:
Name Type Description
eventData object

Event data

Returns:
string
Example
instance.isFlick({
     start: 1000,
     end: 1100,
     list: [
           {
               x: 10,
               y: 10
           },
           {
               x: 11,
               y: 11
           }
     ]
});

isLongTab(pos, callback) → {boolean}

Stop detect longtab roop.

Parameters:
Name Type Description
pos object

A position to end

callback function

A callback function

Returns:
boolean -

State of longtab

Example
instance.isLongTab({
     x: 100,
     y: 150
}, function() {
     console.log('asdf');
});