commit 33d59e16963400c4f940c0c24366c70c4c58ee19
parent d8180febe79b8b0a4f36e77a484a426f22a451d8
Author: Daniel Barlow <dan@telent.net>
Date: Sat, 23 Nov 2024 16:41:04 +0000
extract Model module
Diffstat:
2 files changed, 27 insertions(+), 16 deletions(-)
diff --git a/frontend/src/Main.elm b/frontend/src/Main.elm
@@ -7,6 +7,7 @@ import Html.Attributes as H exposing (src, style, width, height)
import Html.Events exposing (onClick, on)
import Html.Events.Extra.Pointer as Pointer
import Maybe exposing (Maybe)
+import Model exposing (..)
import Lib exposing(..)
import List.Extra exposing(find)
import Json.Decode as D
@@ -52,12 +53,6 @@ main =
-- MODEL
-type DragTarget = Map | Graph | StartMark | EndMark | NoTarget
-
-type Drag
- = None
- | Dragging DragTarget (Int, Int) (Int, Int)
-
dragTo : Drag -> (Int, Int) -> Drag
dragTo d dest =
@@ -76,16 +71,6 @@ dragDelta target d =
subtractTuple (fx,fy) (tx,ty) = (fx-tx, fy-ty)
-type TrackState = Empty | Loading | Failure String | Present (List Point)
-type alias Model =
- { centre: Coord
- , zoom: FineZoomLevel
- , drag: Drag
- , startTime : Float
- , duration : Float
- , markedTime : (Float, Float)
- , track: TrackState }
-
init : () -> Url -> Nav.Key -> (Model, Cmd Msg)
init _ url navKey =
let (start, duration) =
diff --git a/frontend/src/Model.elm b/frontend/src/Model.elm
@@ -0,0 +1,26 @@
+module Model exposing
+ (
+ Model
+ , TrackState(..)
+ , Drag(..)
+ , DragTarget(..)
+ )
+import TileMap exposing (FineZoomLevel, Coord)
+import Point exposing (Point)
+
+type DragTarget = Map | Graph | StartMark | EndMark | NoTarget
+
+type Drag
+ = None
+ | Dragging DragTarget (Int, Int) (Int, Int)
+
+type TrackState = Empty | Loading | Failure String | Present (List Point)
+
+type alias Model =
+ { centre: Coord
+ , zoom: FineZoomLevel
+ , drag: Drag
+ , startTime : Float
+ , duration : Float
+ , markedTime : (Float, Float)
+ , track: TrackState }