commit dfe0a7dbd57ec222f3263c6a129c2695c3fea0b3
parent 7dc7c6b2b00775a65d053a70ab86e238d67584fb
Author: Daniel Barlow <dan@telent.net>
Date: Mon, 25 Nov 2024 21:36:07 +0000
use a Maybe instead of NoTarget
Diffstat:
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/frontend/src/Main.elm b/frontend/src/Main.elm
@@ -145,7 +145,6 @@ handleDragFinish model target (x, y) =
(s, d) = model.markedTime
in (s, d - deltat)
}
- NoTarget -> model
updateModel msg model =
@@ -347,12 +346,12 @@ targetedEventDecoder =
Pointer.eventDecoder
(D.at ["target", "id"] D.string)
-targetFor : String -> DragTarget
+targetFor : String -> Maybe DragTarget
targetFor s =
case s of
- "left-marker" -> StartMark
- "right-marker" -> EndMark
- _ -> NoTarget
+ "left-marker" -> Just StartMark
+ "right-marker" -> Just EndMark
+ _ -> Nothing
onDownWithTarget tag =
let
@@ -439,7 +438,11 @@ timeAxis model points =
svg
[ width portalWidth
, height (graphHeight + 20)
- , onDownWithTarget (\e -> DragStart (targetFor e.targetId) (epos e.pointerEvent))
+ , onDownWithTarget (\e ->
+ case targetFor e.targetId of
+ Just tgt -> DragStart tgt (epos e.pointerEvent)
+ Nothing -> Dribble "drag with unknown target"
+ )
, viewBox ("0 -10 " ++ (String.fromInt portalWidth) ++
" " ++ (String.fromInt (graphHeight + 10)))
]
diff --git a/frontend/src/Model.elm b/frontend/src/Model.elm
@@ -8,7 +8,7 @@ module Model exposing
import TileMap exposing (ZoomLevel, Coord)
import Point exposing (Point)
-type DragTarget = Map | Graph | StartMark | EndMark | NoTarget
+type DragTarget = Map | Graph | StartMark | EndMark
type Drag
= None