Clear the visible cards before loading more

Not quite a loading state, but not quite not a loading state.
This commit is contained in:
Correl Roush 2021-07-15 22:54:46 -04:00
parent 863ab021a6
commit dc3cc6427b

View file

@ -273,7 +273,7 @@ update msg model =
( { model | criteria = newCriteria }, cmd ) ( { model | criteria = newCriteria }, cmd )
Search -> Search ->
( model ( { model | cardPage = Nothing }
, Cmd.batch , Cmd.batch
[ search model.criteria [ search model.criteria
, Browser.Navigation.pushUrl model.navigationKey <| , Browser.Navigation.pushUrl model.navigationKey <|
@ -282,7 +282,16 @@ update msg model =
) )
GetPage url -> GetPage url ->
( model, loadPage url ) let
clearPage maybePage =
case maybePage of
Just page ->
Just { page | values = [] }
Nothing ->
Nothing
in
( { model | cardPage = clearPage model.cardPage }, loadPage url )
FoundCards (Ok cardPage) -> FoundCards (Ok cardPage) ->
( { model | cardPage = Just cardPage }, Cmd.none ) ( { model | cardPage = Just cardPage }, Cmd.none )
@ -314,6 +323,10 @@ viewCardBrowser model =
-- 50% of the Scryfall border_crop image width -- 50% of the Scryfall border_crop image width
240 240
cardHeight =
-- 50% of the Scryfall border_crop image height
340
cardSpacing = cardSpacing =
10 10
@ -329,6 +342,9 @@ viewCardBrowser model =
in in
(max 3 >> min 9) (availableColumns // 3 * 3) (max 3 >> min 9) (availableColumns // 3 * 3)
cardRows =
18 // cardColumns
viewCard cardModel = viewCard cardModel =
E.column [] E.column []
[ E.image [ E.width (E.px cardWidth) ] [ E.image [ E.width (E.px cardWidth) ]
@ -362,7 +378,12 @@ viewCardBrowser model =
E.none E.none
Just cardPage -> Just cardPage ->
E.row [ E.width E.fill, E.centerX ] <| E.row
[ E.width E.fill
, E.height (E.px (cardRows * (cardHeight + cardSpacing)))
, E.centerX
]
<|
[ navButton "" cardPage.prev [ navButton "" cardPage.prev
, E.wrappedRow , E.wrappedRow
[ E.width (E.px (cardColumns * (cardWidth + cardSpacing))) [ E.width (E.px (cardColumns * (cardWidth + cardSpacing)))