-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathFullscreen.elm
50 lines (40 loc) · 949 Bytes
/
Fullscreen.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
module FullScreen exposing (..)
import Task
import Window
import Html exposing (program)
import Html.Events exposing (onInput)
import Maps
import Maps.Map as Map
type Msg
= MapMsg (Maps.Msg ())
| Resize Window.Size
main = program
{ init = init
, update = update
, subscriptions = subscriptions
, view = view
}
init =
( Maps.defaultModel
, Task.attempt (Result.withDefault defaultSize >> Resize) Window.size
)
defaultSize =
Window.Size 500 500
update msg model =
case msg of
MapMsg msg ->
Maps.update msg model
|> Tuple.mapSecond (Cmd.map MapMsg)
Resize size ->
( model
|> Maps.updateMap (Map.setWidth <| toFloat size.width)
|> Maps.updateMap (Map.setHeight <| toFloat size.height)
, Cmd.none
)
subscriptions model =
Sub.batch
[ Sub.map MapMsg <| Maps.subscriptions model
, Window.resizes Resize
]
view model =
Html.map MapMsg <| Maps.view model