gesture

package gesture

Type members

Classlikes

case class Click(p: Vec2d, timestamp: Long) extends GestureEvent
case class Down(p: Vec2d, timestamp: Long) extends PointerState
case class Drag(from: Vec2d, fromTimestamp: Long, to: Vec2d, toTimestamp: Long) extends PointerState
case class DragAbort(from: Vec2d, fromTimestamp: Long, to: Vec2d, toTimestamp: Long) extends GestureEvent
case class DragComplete(from: Vec2d, fromTimestamp: Long, to: Vec2d, toTimestamp: Long, delta: Vec2d) extends GestureEvent
case class DragMove(from: Vec2d, fromTimestamp: Long, to: Vec2d, toTimestamp: Long, delta: Vec2d) extends GestureEvent
case class DragStart(from: Vec2d, fromTimestamp: Long, to: Vec2d, toTimestamp: Long, delta: Vec2d) extends GestureEvent
abstract class GestureAndRegionProcessor[R](dragThreshold: Double, ClickDistThreshold: Double, ClickTimeThreshold: Double)
case class GestureAndRegions[R](gesture: GestureEvent, from: Option[R], to: Option[R])
sealed trait GestureEvent
class GestureProcessor(dragThreshold: Double, ClickDistThreshold: Double, ClickTimeThreshold: Double)
case class Invalid(msg: String, pointerEvent2: PointerAdt) extends GestureEvent
case object Noop extends GestureEvent
sealed trait PointerAdt

We convert from dom.PointerEvent to an internal ADT representation for 3 reasons:

We convert from dom.PointerEvent to an internal ADT representation for 3 reasons:

  • Sealed traits are better in match statements than raw PointerEvents which have a String type field.
  • PointerEvents are hard to create and set timestamps on in unit tests
  • PointerEvents arent always supported in non-dom environments like Nodejs where we might want to test
Companion:
object
object PointerAdt
Companion:
class
case class PointerDown(p: Vec2d, timestamp: Long) extends PointerAdt
case class PointerLeave(p: Vec2d, timestamp: Long) extends PointerAdt
case class PointerMove(p: Vec2d, timestamp: Long) extends PointerAdt
sealed trait PointerState
case class PointerUp(p: Vec2d, timestamp: Long) extends PointerAdt
case class Up() extends PointerState

Types

type Vec2d = (Double, Double)

Extensions

Extensions

extension (v: Vec2d)
def +(other: Vec2d): (Double, Double)
def -(other: Vec2d): (Double, Double)
def distanceTo(other: Vec2d): Double