GoldentTuft/elm-infinite-scroll/1.0.0

InfScroll

Type

type Status
= Loading
| Loaded
| Loadable
| Stop
type Dir
= Top
| Bottom
type Msg
type alias DomId =
String

Init

init : DomId -> Dir -> InfScroll
InfScroll.init "item-list" InfScroll.Bottom
    |> setOffset 100

Update

update : Msg -> InfScroll -> ( InfScroll, Cmd Msg )
(Msg -> msg)
-> Cmd msg
-> ( InfScroll, Cmd Msg )
-> ( InfScroll, Cmd msg )
MapInfScroll subMsg ->
    let
        (newInfScroll, cmd) =
            InfScroll.update subMsg model.infScroll
                |> InfScroll.whenLoadMore MapInfScroll getItems
    in
    ( { model | infScroll = newInfScroll }
    , cmd
    )
GotItems items ->
    ( { model
        | items =
            List.sort (model.items ++ items)
        , infScroll =
            if List.isEmpty items then
                InfScroll.toStop model.infScroll


            else
                InfScroll.toLoaded model.infScroll
        }
    , Cmd.none
    )

View

-> List (Attribute msg)
-> List (Attribute msg)
-> List (Html msg)
-> Html msg
InfScroll.view model.infScroll
    (InfScroll.defaultContainerAttrs infScroll)
    (InfScroll.defaultItemsAttrs infScroll)
    (List.map viewItem model.items)
defaultContainerAttrs : InfScroll -> List (Attribute msg)
defaultItemsAttrs : InfScroll -> List (Attribute msg)

Get

getViewport : InfScroll -> Maybe Viewport