Commit 5770050a authored by Cédric F.'s avatar Cédric F.

Fetch current time upon init for faster loading

parent 7ad684b6
......@@ -3,6 +3,8 @@ module Lifechart.Update exposing (init, update)
import Navigation
import Date
import DateExtra
import Time
import Task
import Color.Convert
import Lifechart.Model exposing (..)
import Lifechart.Serializer as Serializer
......@@ -16,7 +18,7 @@ init location =
|> Result.toMaybe
|> Maybe.withDefault initialModel
in
( model, Cmd.none )
( model, Task.perform Tick Time.now )
update : Msg -> Model -> ( Model, Cmd Msg )
......
......@@ -9,13 +9,15 @@ import Lifechart.View.Controls as Controls
view : Model -> Html Msg
view model =
if model.now == 0 then
h1 [ class "text-xs-center" ] [ text "Loading..." ]
else
div []
[ Controls.modal model
, div [ class "row" ]
[ div [ class "col-xs-6" ] [ Controls.controls model ]
, div [ class "col-xs-6" ] [ Canvas.canvas model ]
div []
[ Controls.modal model
, div [ class "row" ]
[ div [ class "col-xs-6" ] [ Controls.controls model ]
, div [ class "col-xs-6" ]
[ if model.now == 0 then
h1 [ class "text-xs-center" ] [ text "Loading..." ]
else
Canvas.canvas model
]
]
]
......@@ -70,9 +70,11 @@ canvas model =
theLegend =
legend model
|> Collage.moveX (canvasWidth / 2 - legendWidth + lineHeight)
form =
Collage.group [ grid, theLegend ]
in
Collage.collage canvasWidth (ceiling height) [ grid, theLegend ]
|> Element.toHtml
Collage.collage canvasWidth (ceiling height) [ form ] |> Element.toHtml
legend : Model -> Form
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment