Skip to content

Commit

Permalink
[ new ] wheel events
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-hoeck committed Jul 21, 2023
1 parent 2517a5e commit c561e18
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Text/HTML/Event.idr
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ import Data.Maybe
-- Event Info Types
--------------------------------------------------------------------------------

public export
record WheelInfo where
constructor MkWheelInfo
deltaMode : Bits32
deltaX : Double
deltaY : Double
deltaZ : Double

public export
record MouseInfo where
constructor MkMouseInfo
Expand Down Expand Up @@ -85,3 +93,6 @@ data DOMEvent : Type -> Type where

-- Routing
HashChange : a -> DOMEvent a

-- Wheel
Wheel : (WheelInfo -> Maybe a) -> DOMEvent a
1 change: 1 addition & 0 deletions src/Web/MVC/Cmd.idr
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ parameters {0 e : Type}
MouseOut f => inst "mouseout" mouseInfo f
MouseMove f => inst "mousemove" mouseInfo f
HashChange v => inst "hashchange" {t = Event} (const $ pure v) Just
Wheel f => inst "wheel" wheelInfo f

where
inst :
Expand Down
9 changes: 9 additions & 0 deletions src/Web/MVC/Event.idr
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,12 @@ changeInfo e =
[| MkInputInfo
(primIO (prim__input e))
((1 ==) <$> primIO (prim__checked e)) |]

export
wheelInfo : WheelEvent -> JSIO WheelInfo
wheelInfo e =
[| MkWheelInfo
(deltaMode e)
(deltaX e)
(deltaY e)
(deltaZ e) |]

0 comments on commit c561e18

Please sign in to comment.