fix: Mouse.buttonFromString
This commit is contained in:
parent
f299c7d467
commit
6b76f4c955
@ -5,6 +5,8 @@ module Puppeteer.Mouse
|
|||||||
, up
|
, up
|
||||||
, moveTo
|
, moveTo
|
||||||
, click
|
, click
|
||||||
|
, mouseButtonToString
|
||||||
|
, mouseButtonFromString
|
||||||
, MouseWheelOptions
|
, MouseWheelOptions
|
||||||
, MouseMoveOptions
|
, MouseMoveOptions
|
||||||
, MouseOptions
|
, MouseOptions
|
||||||
@ -15,6 +17,13 @@ import Prelude
|
|||||||
|
|
||||||
import Control.Promise (Promise)
|
import Control.Promise (Promise)
|
||||||
import Control.Promise as Promise
|
import Control.Promise as Promise
|
||||||
|
import Data.Bounded.Generic (genericBottom, genericTop)
|
||||||
|
import Data.Enum (class BoundedEnum, class Enum, upFrom)
|
||||||
|
import Data.Enum.Generic (genericCardinality, genericFromEnum, genericPred, genericSucc, genericToEnum)
|
||||||
|
import Data.Foldable (find)
|
||||||
|
import Data.Generic.Rep (class Generic)
|
||||||
|
import Data.Maybe (Maybe)
|
||||||
|
import Data.Show.Generic (genericShow)
|
||||||
import Effect (Effect)
|
import Effect (Effect)
|
||||||
import Effect.Aff (Aff)
|
import Effect.Aff (Aff)
|
||||||
import Prim.Row (class Nub, class Union)
|
import Prim.Row (class Nub, class Union)
|
||||||
@ -30,6 +39,25 @@ data MouseButton
|
|||||||
| MouseBack
|
| MouseBack
|
||||||
| MouseForward
|
| MouseForward
|
||||||
|
|
||||||
|
derive instance Generic MouseButton _
|
||||||
|
derive instance Eq MouseButton
|
||||||
|
derive instance Ord MouseButton
|
||||||
|
instance Show MouseButton where
|
||||||
|
show = genericShow
|
||||||
|
|
||||||
|
instance Enum MouseButton where
|
||||||
|
pred = genericPred
|
||||||
|
succ = genericSucc
|
||||||
|
|
||||||
|
instance Bounded MouseButton where
|
||||||
|
top = genericTop
|
||||||
|
bottom = genericBottom
|
||||||
|
|
||||||
|
instance BoundedEnum MouseButton where
|
||||||
|
cardinality = genericCardinality
|
||||||
|
toEnum = genericToEnum
|
||||||
|
fromEnum = genericFromEnum
|
||||||
|
|
||||||
mouseButtonToString :: MouseButton -> String
|
mouseButtonToString :: MouseButton -> String
|
||||||
mouseButtonToString MouseLeft = "left"
|
mouseButtonToString MouseLeft = "left"
|
||||||
mouseButtonToString MouseRight = "right"
|
mouseButtonToString MouseRight = "right"
|
||||||
@ -37,6 +65,9 @@ mouseButtonToString MouseMiddle = "middle"
|
|||||||
mouseButtonToString MouseBack = "back"
|
mouseButtonToString MouseBack = "back"
|
||||||
mouseButtonToString MouseForward = "forward"
|
mouseButtonToString MouseForward = "forward"
|
||||||
|
|
||||||
|
mouseButtonFromString :: String -> Maybe MouseButton
|
||||||
|
mouseButtonFromString s = find (eq s <<< mouseButtonToString) (upFrom bottom :: Array MouseButton)
|
||||||
|
|
||||||
type MouseWheelOptions r = (deltaX :: Number, deltaY :: Number | r)
|
type MouseWheelOptions r = (deltaX :: Number, deltaY :: Number | r)
|
||||||
type MouseMoveOptions r = (steps :: Number | r)
|
type MouseMoveOptions r = (steps :: Number | r)
|
||||||
type MouseOptions r = (button :: MouseButton | r)
|
type MouseOptions r = (button :: MouseButton | r)
|
||||||
|
Loading…
Reference in New Issue
Block a user