Creates a slider based on the SwiperJS API. Allows building styles depending on the options passed to the SwiperJS API and setting options based on the styles as well.

The order in which the options are getting applied is:

  • options
  • varsToOptions
  • numbersToOptions
  • unitsToOptions
  • optionsToCss

Latter options overwrite earlier.

You can set nested hylo-slide components to 'display: none;' for certain breakpoints. The hylo-slider takes care of adding/removing the correct slides depending on the current breakpoint. In order to work, a hylo-breakpoint-listener component needs to be present. Does not work for looped slider!

Used slots:

  • default: hylo-slide components
  • previous: the content of the previous element
  • next: the content of the next element
  • additional: put after the actual slider and beneath the host (hylo-slider) component

slidesPerView has to be set through one of the "options" properties.

Used css variables:

  • --hylo-slider-bullet-size: 8px
  • --hylo-slider-bullet-background: white
  • --hylo-slider-bullet-border-width: 0px
  • --hylo-slider-bullet-border-color: black
  • --hylo-slider-bullet-border-color-active: var(--hylo-slider-bullet-border-color)
  • --hylo-slider-bullet-opacity: 0.2
  • --hylo-slider-bullet-background-active: var(--hylo-slider-bullet-background)
  • --hylo-slider-bullet-opacity-active: 1
  • --hylo-slider-scrollbar-padding: 20px
  • --hylo-slider-scrollbar-height: 10px
  • --hylo-slider-scrollbar-background-color: white
  • --hylo-slider-scrollbar-handle-color: black
  • --hylo-slider-scrollbar-border-color: var(--hylo-slider-scrollbar-handle-color)
  • --hylo-slider-scrollbar-opacity: 1

Requires SwipeJs: npm install swiper --save-dev

Update from earlier versions:

  • replace all appearances (style classes, element queries ...) of "ion-slides" with ".swiper-container" or "hylo-slider .swiper-container"
  • replace all appearances (style classes, element queries ...) of "ion-slide" with "hylo-slide" or ".swiper-slide" or "hylo-slider .swiper-slide"

Properties

controlsClass: string = ''

Classes added to the controls (".swiper-controls") element.

dimensionsUpdate: boolean

Updates on breakpoint or orientation change.

direction: "horizontal" | "vertical" = 'horizontal'

The direction of the slider.

Default: "horizontal"

grid: boolean

By default the slider is using a flex style. With this option the slider will use a grid style.

labelEnd: string = 'Ende'

Label used for a hidden marker at the end of the slider. Can also be set trough the translations object of hylo-page-root.

labelSlider: string = 'Slider'

Label used for a hidden marker at the beginning and the end of the slider. Can also be set trough the translations object of hylo-page-root.

labelStart: string = 'Start'

Label used for a hidden marker at the beginning of the slider. Can also be set trough the translations object of hylo-page-root.

list: string | boolean

Defines the slider as list and is recognized as such by screen readers. Does not work on looped slider.

If set as string, the string is used as label of the list.

loop: boolean

Should the slider loop. Be aware that this causes slides to be cloned which might create problems for wrapped WebComponents.

loopButton: boolean

Does not create a looping slider but jumps to the first slide when at the last slider and moving to the next and jumping to the last slide when at the first slide and moving to the previous.

nextClass: string = ''

Classes added to the next element.

numbersToOptions: any = {}

Same as "varsToOptions" only that the computed values will be converted into numbers (parseFloat). Has to be still a set of key/value pairs where the values are CSS VARIABLES!

As object or JSON string of the object.

e.g. {spaceBetween: "--padding"} or '{"spaceBetween": "--padding"}' as string

Also possible to set different settings for different breakpoints. Triggers an update on breakpoint change. A hylo-breakpoint-listener needs to be present.

e.g. {xs: {...}, default: {...}}

options: any = {}

Options for SwiperJS API as object or JSON string of the object.

e.g. {slidesOffsetBefore: 0, slidesPerView: 1} or '{"slidesOffsetBefore": 0, "slidesPerView": 1}' as string

Also possible to set different settings for different breakpoints. Triggers an update on breakpoint change. A hylo-breakpoint-listener needs to be present.

e.g. {xs: {...}, default: {...}}

optionsToCss: any = {}

Options which will be added to the SwiperJS API options and as css variables to the hylo-slider component. To add the computed value of a "varsToOptions", "numbersToOptions" or "unitsToOptions" option as css variable, add the option to this object as well but with the value of false.

The keys will be prefixed with "--". Can be used like this in css:

  • width: calc(100% / var(--slidesPerView) - var(--spaceBetween) * (var(--slidesPerView) - 1) / var(--slidesPerView) * 1px);

As object or JSON string of the object.

e.g. {slidesPerView: 3, spaceBetween: false} or '{"slidesPerView": 3, "spaceBetween": false}' as string

Also possible to set different settings for different breakpoints. Triggers an update on breakpoint change. A hylo-breakpoint-listener needs to be present.

e.g. {xs: {...}, default: {...}}

overflow: boolean

By default items outside the slider width are hidden. When set, items outside the slider are shown.

pager: boolean = false

If true, show the pagination. Will be placed inside the ".swiper-controls".

pagerActive: boolean = false

If set, the bulletins of the pager are clickable.

playInterval: number = 3000

The auto play interval in milliseconds.

To set individuell intervals between slides, set the attribute "data-swiper-autoplay" on a slide.

prevClass: string = ''

Classes added to the previous element.

sameSize: boolean

If set, the hylo-slide components are gonna have all the height/width (horizontal/vertical) of the biggest slide.

scrollbar: boolean = false

If true, show the scrollbar.

The scrollbar needs to be styled.

shakeIt: string | boolean

Shakes the active slide for a sec after the transition to it finished.

Can be set as boolean or as a comma separated string of breakpoints.

showPause: boolean

Shows a pause/play button. Will be placed inside the ".slider-controls" after the pager. Property "startPlay" needs to be set.

When used with hylo-nav and/or hylo-router, the autoplay should be "stopAutoplay()" on "componentWillDeactivate" (see hylo-nav, hylo-router).

showPrevNext: boolean

Adds unstyled elements with the class "hylo-slider-previous" and "hylo-slider-next" before and after the slider area respectively. You are in charge of positioning and styling them correctly. Use the slots "previous" and "next" to fill the elements.

The previous and next element are link to the slidePrevious and slideNext methods.

startPlay: boolean

Starts autoplay when loaded.

stopCounter: number = 0

Stops a running auto play loop when the counter reaches 0. Counts down every time the slider starts over again.

type: string = ""

Define the type of the slider.

Depending on the type, additional functionality or styles will be added to the slider. The type will be added as class to the component. (No types with additional functionality defined yet)

unitsToOptions: any = {}

Same as "numbersToOptions" only that the computed numbers are multiplied by "--hylo-unit". Has to be still a set of key/value pairs where the values are CSS VARIABLES!

As object or JSON string of the object.

e.g. {spaceBetween: "--hylo-page-padding"} or '{"spaceBetween": "--hylo-page-padding"}' as string

Also possible to set different settings for different breakpoints. Triggers an update on breakpoint change. A hylo-breakpoint-listener needs to be present.

e.g. {xs: {...}, default: {...}}

varsToOptions: any = {}

Set of key/value pairs where the values are CSS VARIABLES! The css variables will be replaced with their computed values from the hylo-slider component. The transformed object will be added to the SwiperJS API options.

As object or JSON string of the object.

Also possible to set different settings for different breakpoints. Triggers an update on breakpoint change. A hylo-breakpoint-listener needs to be present.

e.g. {xs: {...}, default: {...}}

watchResize: boolean = false

If set, the slider watches for window resizes and sets the css variable "--hylo-slider-width" with its width and calls for an update of the slider when a width change occurs.

wontChangeScrollbarProp: boolean = false

Set to true for optimization if you will not change the scrollbar property in the future.

Methods

  • Returns void

    Interval

  • Get the index of the active slide. Might differ form getIndex() in a looped slider because of duplicated slides. Counts the duplicated slides.

    Returns Promise<any>

  • Get the index of the current slide. Makes no differences between looped and not looped slider.

    Returns Promise<any>

  • Get the index of the previous active slide.

    Returns Promise<any>

  • Get whether or not the current slide is the first slide.

    Returns Promise<any>

  • Get whether or not the current slide is the last slide.

    Returns Promise<any>

  • Get the total number of slides.

    Returns Promise<any>

  • Lock or unlock the ability to slide to the next slide.

    Parameters

    • lock: boolean

    Returns Promise<void>

  • Lock or unlock the ability to slide to the previous slide.

    Parameters

    • lock: boolean

    Returns Promise<void>

  • Lock or unlock the ability to slide to the next or previous slide.

    Parameters

    • lock: boolean

    Returns Promise<void>

  • Replaces the current slides with new ones.

    Parameters

    • slides: HTMLHyloSlideElement[]

      an array of hylo-slide elements

    Returns Promise<any>

  • Transition to the next slide.

    Parameters

    • Optional speed: number
    • Optional runCallbacks: boolean

    Returns Promise<void>

  • Transition to the previous slide.

    Parameters

    • Optional speed: number
    • Optional runCallbacks: boolean

    Returns Promise<void>

  • Transition to the specified slide.

    Parameters

    • index: number
    • Optional speed: number
    • Optional runCallbacks: boolean

    Returns Promise<void>

  • Start auto play. Property "startPlay" needs to be set.

    Returns Promise<void>

  • Stop auto play. Sets the "stopCounter" to 0. Property "startPlay" needs to be set.

    Returns Promise<void>

  • Update the underlying slider implementation. Call this if you've added or removed child slides.

    Parameters

    • visibility: boolean = false

      set if you changed the display style of a slide from or to "none"

    Returns Promise<void>

Events

hyloSliderAutoplayStart: EventEmitter<any>

Fired when auto play starts.

hyloSliderAutoplayStop: EventEmitter<any>

Fired when auto play stops.

hyloSliderDidChange: EventEmitter<any>

Fired when slide changed.

hyloSliderDidLoad: EventEmitter<any>

Fired when the slider and its SwiperJS API is initialised.

hyloSliderReachEnd: EventEmitter<any>

Fired when slider reached the end.

hyloSliderReachStart: EventEmitter<any>

Fired when slider reached the beginning.

hyloSliderTransitionEnd: EventEmitter<any>

Fired when transition to next slide ends.

hyloSliderTransitionStart: EventEmitter<any>

Fired when transition to next slide starts.

hyloSliderWillChange: EventEmitter<any>

Fired when slide will change.

ionSlideDidChange: EventEmitter<any>

Same as "hyloSliderDidChange".

Deprecated

ionSlideReachEnd: EventEmitter<any>

Same as "hyloSliderReachEnd".

Deprecated

ionSlideReachStart: EventEmitter<any>

Same as "hyloSliderReachStart".

Deprecated

ionSlideTransitionEnd: EventEmitter<any>

Same as "hyloSliderTransitionEnd".

Deprecated

ionSlideTransitionStart: EventEmitter<any>

Same as "hyloSliderTransitionStart".

Deprecated

ionSlideWillChange: EventEmitter<any>

Same as "hyloSliderWillChange".

Deprecated

ionSlidesDidLoad: EventEmitter<any>

Same as "hyloSliderDidLoad".

Deprecated

Generated using TypeDoc