DragController

semagrams.controllers.DragController
See theDragController companion object
class DragController() extends Controller

A wrapper around a Var containing state that keeps track of the current object being dragged. This has to be global because it is easy for something that is being dragged to not be under the mouse, so the mouse-move events have to come from the global window.

When the state is non-None, mouse move events get their position sent to the observer. On mouse-up or when the mouse leaves the parent svg, the drag-end handler is called and the state is reset to be None.

Attributes

Companion:
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Concise view

Value members

Concrete methods

def apply(es: EditorState, elt: SvgElement): Unit

Hooks up the event stream from editor state to update the drags

Hooks up the event stream from editor state to update the drags

Attributes

elt

the element that the binding is attached to

es

the EditorState that the events come from

def drag[Model](observer: Observer[Complex]): IO[Unit]

Returns an IO action that completes when the drag is over

Returns an IO action that completes when the drag is over

Attributes

observer

the observer that gets updated mouse positions during the drag

def dragStart[Model](observer: Observer[Complex]): IO[Unit]

Returns an IO action that starts a drag, and completes immediately

Returns an IO action that starts a drag, and completes immediately

Attributes

observer

the observer that gets updated mouse positions during the drag

def processEvent(state: Option[State], evt: Event): Option[State]

Processes mouse events by updating state.

Processes mouse events by updating state.

Attributes

evt

the event to process

state

the current state

Concrete fields

val $state: Var[Option[State]]