From f5c19d2061e03ef28c45efd839bb211e446b25f6 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Sun, 7 Mar 2021 19:38:32 +0100 Subject: do not load all slides at once to prevent noticable load times when switching slides, picarones previously loaded all slides at once, and then only displayed whichever one was applicable. This cause problems with larger slidesets; instead, it now loads the current slides and the two previous and next slides (wrapping around at the end/beginning). --- picarones-elm/src/Main.elm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/picarones-elm/src/Main.elm b/picarones-elm/src/Main.elm index 56cf48f..014d2f4 100644 --- a/picarones-elm/src/Main.elm +++ b/picarones-elm/src/Main.elm @@ -82,10 +82,14 @@ body model = div [] -- that these are all loaded on startup, with visibility done through -- z indices so we won't have lags while switching between them. slideView : Int -> Int -> String -> List (Html Msg) -slideView i max prefix = List.range 0 (max - 1) +slideView i max prefix = mkInterval i max -- List.range 0 (max - 1) |> List.map (\x -> (prefix ++ (padNum 2 (x+1)) ++ ".png", x == i)) |> List.map (\(path,t) -> img [src path, onTop t] []) +mkInterval : Int -> Int -> List Int +mkInterval i m = List.range (i-2) (i+2) + |> List.map (\x -> modBy m x) + onTop t = style "z-index" (String.fromInt (if t then 10 else 0)) -- format an int with prefixed 0's — apparently elm doesn't have a -- cgit v1.2.3