commit 7fe09053e3e0a789cdbef8962a718c7b6503e9c3
parent 8c1eb9f77f8a9833694e7ca90c1d16559f79c8fe
Author: Daniel Barlow <dan@telent.net>
Date: Sat, 16 Nov 2024 00:00:16 +0000
remove MapZoom{In,Out} messages
they can both be replaced with MapScale
Diffstat:
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/frontend/src/Main.elm b/frontend/src/Main.elm
@@ -177,9 +177,7 @@ fetchTrack start duration = Http.get
-- UPDATE
type Msg
- = MapZoomIn
- | MapZoomOut
- | MapScale Float
+ = MapScale Int
| PointerDown (Int, Int)
| PointerMove (Int, Int)
| PointerUp (Int, Int)
@@ -195,15 +193,8 @@ update msg model = (newModel msg model, Cmd.none)
newModel msg model =
case msg of
- MapZoomIn ->
- { model | zoom = incZoom model.zoom zoomStep }
-
- MapZoomOut ->
- { model | zoom = incZoom model.zoom -zoomStep }
-
MapScale y ->
- let dir = floor(abs(y)/y)
- in { model | zoom = incZoom model.zoom dir }
+ { model | zoom = incZoom model.zoom y }
PointerDown (x,y) ->
{ model | drag = Dragging (x,y) (x,y) }
@@ -420,7 +411,8 @@ withSwallowing m =
-- FIXME should do something useful with deltaMode as well as deltaY
mapWheelDecoder =
- D.map (withSwallowing << MapScale) (D.field "deltaY" D.float)
+ let sgn x = floor((abs x)/x)
+ in D.map (withSwallowing << MapScale << sgn) (D.field "deltaY" D.float)
timeWheelDecoder =
D.map (withSwallowing << TimeScale) (D.field "deltaY" D.float)
@@ -443,8 +435,8 @@ viewDiv model =
[canvasV]
, text ("Zoom level " ++ (String.fromInt (toZoom model.zoom)))
, span []
- [ button [ onClick MapZoomOut ] [ text "-" ]
- , button [ onClick MapZoomIn ] [ text "+" ]
+ [ button [ onClick (MapScale -zoomStep) ] [ text "-" ]
+ , button [ onClick (MapScale zoomStep) ] [ text "+" ]
]
]
, div [ style "display" "flex"