Clear the visible cards before loading more
Not quite a loading state, but not quite not a loading state.
This commit is contained in:
parent
863ab021a6
commit
dc3cc6427b
1 changed files with 24 additions and 3 deletions
|
@ -273,7 +273,7 @@ update msg model =
|
|||
( { model | criteria = newCriteria }, cmd )
|
||||
|
||||
Search ->
|
||||
( model
|
||||
( { model | cardPage = Nothing }
|
||||
, Cmd.batch
|
||||
[ search model.criteria
|
||||
, Browser.Navigation.pushUrl model.navigationKey <|
|
||||
|
@ -282,7 +282,16 @@ update msg model =
|
|||
)
|
||||
|
||||
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) ->
|
||||
( { model | cardPage = Just cardPage }, Cmd.none )
|
||||
|
@ -314,6 +323,10 @@ viewCardBrowser model =
|
|||
-- 50% of the Scryfall border_crop image width
|
||||
240
|
||||
|
||||
cardHeight =
|
||||
-- 50% of the Scryfall border_crop image height
|
||||
340
|
||||
|
||||
cardSpacing =
|
||||
10
|
||||
|
||||
|
@ -329,6 +342,9 @@ viewCardBrowser model =
|
|||
in
|
||||
(max 3 >> min 9) (availableColumns // 3 * 3)
|
||||
|
||||
cardRows =
|
||||
18 // cardColumns
|
||||
|
||||
viewCard cardModel =
|
||||
E.column []
|
||||
[ E.image [ E.width (E.px cardWidth) ]
|
||||
|
@ -362,7 +378,12 @@ viewCardBrowser model =
|
|||
E.none
|
||||
|
||||
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
|
||||
, E.wrappedRow
|
||||
[ E.width (E.px (cardColumns * (cardWidth + cardSpacing)))
|
||||
|
|
Loading…
Reference in a new issue