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