nixCodeX/elm-bootstrap/2.1.0

NOTE: the latest version is 3.1.1

Renamed to aDifferentJT/elm-bootstrap. That is where the repository lives now. It has not been published as a package under the new name.

Versions published as nixCodeX/elm-bootstrap still install under that name. 13 versions of 13 come from the new location (see their notes).

Rerouted (renamed, verified). The GitHub user or repository was renamed. The tag is still there, at the new name. The Lamdera package server serves a copy recovered from https://github.com/aDifferentJT/elm-bootstrap.

What we checked: The repo moved to github.com/aDifferentJT/elm-bootstrap. Rebuilt with git archive from commit da8645b1cd89 of https://github.com/aDifferentJT/elm-bootstrap (zip prefix nixCodeX-elm-bootstrap-da8645b/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 f18e039a14f9a8efe5c0cee7ceb6e3fc5508da5c.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/nixCodeX/elm-bootstrap/zipball/2.1.0/

Bootstrap.Carousel

A carousel is a slideshow for cycling through a series of content.

Model

type State

State is indexed by the TransitionStage Transition type, to easily pattern match on the states the model can be in.

type alias StateOptions =
{ interval : Maybe Int
, keyboard : Bool
, pauseOnHover : Bool
, cycling : Cycling
, wrap : Bool
, startIndex : Int
}

Configuration for the State

An initial State with the defaultStateOptions

initialStateWithOptions : StateOptions -> State

An initial state with customized options

myOptions =
    { defaultStateOptions
        | interval = Just 2000
        , pauseOnHover = False
    }


init =
    initialStateWithOptions myOptions
defaultStateOptions : StateOptions
type Cycling

when to start automatically cycling the slides

  • Paused: frozen on the current slide
  • Active: immediately start cycling
  • WaitForUser: Wait for the user to perform one transition, then cycle automatically

Update

Update the carousel

Typically called from your main update function

update : Msg -> Model -> ( Model, Cmd Msg )
update message model =
    case message of
        CarouselMsg submsg ->
            ( { model | carouselState = Carousel.update submsg model.carouselState }
            , Cmd.none
            )
type Msg

Internal Msg type

toSlide : Int -> State -> State

Move the carousel to the nth slide

When the transition is invalid, nothing will happen.

Stop a carousel from automatically cycling.

(Re)start automatically cycling.

View

type Config msg

Opaque type that defines the view configuration of a carousel

config : (Msg -> msg) -> List (Attribute msg) -> Config msg

Creates an initial/default view configuration for a carousel

view : State -> Config msg -> Html msg

Create a carousel element

Carousel.config CarouselMsg []
    |> Carousel.withIndicators
    |> Carousel.slides
        [ slideOne model -- view function to create a Slide
        , slideTwo model
        ]
    |> Carousel.view model.carouselState
  • state The current view state
  • config The configuration for the display of the carousel
slides : List (Config msg) -> Config msg -> Config msg

Add slides

Adds previous and next controls

Add indicators

Subscriptions

subscriptions : State -> (Msg -> msg) -> Sub msg

When using automatic cycling you must remember to call this function in your main subscriptions function

subscriptions : Model -> Sub Msg
subscriptions model =
    Carousel.subscriptions model.carouselState CarouselMsg
  • state The current view state of the carousel
  • toMsg Message constructor function that is used to step the view state forward