Stop tracking window size
This commit is contained in:
parent
5d5ac77d41
commit
673c802f91
26
src/Main.elm
26
src/Main.elm
|
@ -37,7 +37,6 @@ main = Browser.application
|
|||
type Msg
|
||||
= Noop
|
||||
| Click Int Int Int Int
|
||||
| WindowSize Int Int
|
||||
| SetTileText Int Int String
|
||||
| AddTile Int
|
||||
| TileDeselected Int
|
||||
|
@ -45,9 +44,7 @@ type Msg
|
|||
| NewMousePos Int Int
|
||||
|
||||
type alias Model =
|
||||
{ windowW: Int
|
||||
, windowH: Int
|
||||
, columns: Array Column
|
||||
{ columns: Array Column
|
||||
, heldTile: Maybe HeldTile
|
||||
, mousePos: (Int, Int)
|
||||
}
|
||||
|
@ -70,15 +67,9 @@ type alias HeldTile =
|
|||
|
||||
blankTile = { text = "", stickers = [] }
|
||||
|
||||
viewportToWindowSize : Viewport -> Msg
|
||||
viewportToWindowSize { viewport } =
|
||||
WindowSize (round viewport.width) (round viewport.height)
|
||||
|
||||
init : () -> Url -> Key -> (Model, Cmd Msg)
|
||||
init flags url browserKey =
|
||||
{ windowW = 1
|
||||
, windowH = 1
|
||||
, columns =
|
||||
{ columns =
|
||||
[ { name = "Into"
|
||||
, tiles = Array.empty
|
||||
}
|
||||
|
@ -100,15 +91,11 @@ init flags url browserKey =
|
|||
, tile = Tile "hello!" []
|
||||
}
|
||||
}
|
||||
|> withCmd (
|
||||
getViewport
|
||||
|> Task.perform viewportToWindowSize
|
||||
)
|
||||
|> withoutCmd
|
||||
|
||||
subscriptions : Model -> Sub Msg
|
||||
subscriptions model = Sub.batch
|
||||
[ onResize WindowSize
|
||||
, if (isJust model.heldTile)
|
||||
[ if (isJust model.heldTile)
|
||||
then onMouseMove <|
|
||||
D.map2 NewMousePos
|
||||
(D.field "pageX" D.int)
|
||||
|
@ -117,7 +104,7 @@ subscriptions model = Sub.batch
|
|||
]
|
||||
|
||||
view : Model -> Browser.Document Msg
|
||||
view {windowW, windowH, columns, heldTile, mousePos} =
|
||||
view {columns, heldTile, mousePos} =
|
||||
[ section
|
||||
[ class "columns"
|
||||
]
|
||||
|
@ -243,9 +230,6 @@ modColumnInPage columnIndex f model =
|
|||
update : Msg -> Model -> (Model, Cmd Msg)
|
||||
update msg model = case Debug.log "UPDATE" msg of
|
||||
Noop -> (model, Cmd.none)
|
||||
WindowSize w h ->
|
||||
{ model | windowW = w, windowH = h }
|
||||
|> withoutCmd
|
||||
Click columnIndex tileIndex x y ->
|
||||
(modColumnInPage columnIndex << modTileInColumn tileIndex)
|
||||
(addStickerToTile <| Sticker (TextSticker "red" "<3") "Into This" x y)
|
||||
|
|
Loading…
Reference in a new issue