aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstuebinm2021-03-07 19:38:32 +0100
committerstuebinm2021-03-07 19:38:32 +0100
commitf5c19d2061e03ef28c45efd839bb211e446b25f6 (patch)
tree3b85e3f7d6bc43366859b2c3446ffa80cea46f0c
parent8b3ca704c66d7815e6f932e92a493f9aae44d74b (diff)
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).
-rw-r--r--picarones-elm/src/Main.elm6
1 files changed, 5 insertions, 1 deletions
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