KotasJS

The worlds first open-source library for handling mouse gestures.

new KotasJS()

Version:
  • 1.0.0
Author:
License:
See:

Members


LINE_LENGTH

Type:
  • number
Properties:
Name Type Description
LINE_LENGTH number Line length for swipe detection
Default Value:
  • 150
Example
let kotas = new KotasJS({linelength:200})

TRESHOLD

Type:
  • number
Properties:
Name Type Description
TRESHOLD number Treshold for swipe detection
Default Value:
  • 50
Example
let kotas = new KotasJS({treshold:100})

Methods


on(event, callback)

Currently there are only 4 events right now: swipe_down, swipe_up, swipe_left, swipe_right

Parameters:
Name Type Description
event number | string Event name
callback function Callback function
Returns:
Examples
// Listen to all mouse gestures
kotas.on("*", (e) => {
 alert(e.event)
})
// Listen to Swipe Down event
kotas.on("swipe_down", (e) => {
 alert(e.event)
})
// Listen to Swipe Up event
kotas.on("swipe_up", (e) => {
 alert(e.event)
})
// Listen to Swipe Left event
kotas.on("swipe_left", (e) => {
 alert(e.event)
})
// Listen to Swipe Right event
kotas.on("swipe_right", (e) => {
 alert(e.event)
})

Type Definitions


ReturnObject

Type:
  • Object
Properties:
Name Type Description
id number Event id (0)
event string Event name (swipe_down)
eventshort string Event short name (down)
startX number Start X coordinate (370)
startY number Start Y coordinate (273)
endX number End X coordinate (400)
endY number End Y coordinate (231)