miso-flow
LicenseBSD3-style (see the file LICENSE)
Safe HaskellNone
LanguageHaskell2010

Miso.Flow.Utils.Dom

Description

Port of utils/dom.ts from @xyflow/system. These functions need a live DOM, so unlike the rest of Miso.Flow.Utils they run in IO (call them from update effects, not from view).

Synopsis

Documentation

getDimensions :: DOMRef -> IO Dimensions Source #

offsetWidth / offsetHeight of an element.

getBoundingRect :: DOMRef -> IO Rect Source #

getBoundingClientRect() as a Rect.

getHostForElement :: DOMRef -> IO JSVal Source #

Root node (document or shadow root) hosting the element.

isInputDOMNode :: JSVal -> IO Bool Source #

True when the (keyboard) event targets an input-like element or an element inside .nokey.

isMouseEvent :: JSVal -> IO Bool Source #

True when the event carries mouse (not touch) coordinates.

getEventPosition :: JSVal -> Maybe Rect -> IO XYPosition Source #

Client position of a mouse or touch event, optionally relative to the given bounds.

data PointerPosition Source #

Pointer position in flow coordinates, with the snapped variant used to skip no-movement drag events.

getPointerPosition Source #

Arguments

:: JSVal

mouse or touch event

-> Transform 
-> Bool

snap to grid

-> Maybe SnapGrid 
-> Maybe Rect

container bounds

-> IO PointerPosition 

Port of getPointerPosition.

getHandleBounds Source #

Arguments

:: HandleType 
-> DOMRef

node element

-> Rect

node bounds (client rect)

-> Double

zoom

-> NodeId 
-> IO (Maybe [Handle]) 

Measure the handles of the given type inside a node element, relative to the node; port of getHandleBounds.