Swiper - v12.0.3
    Preparing search index...

    Class SwiperClass

    Hierarchy (View Summary)

    Implements

    Implemented by

    Index

    Constructors

    • Constructs a new Swiper instance.

      Parameters

      Returns SwiperClass

    Properties

    activeIndex: number

    Index number of currently active slide

    Note, that in loop mode active index value will be always shifted on a number of looped slides

    allowSlideNext: boolean

    Disable / enable ability to slide to the next slides by assigning false / true to this property

    allowSlidePrev: boolean

    Disable / enable ability to slide to the previous slides by assigning false / true to this property

    allowTouchMove: boolean

    Disable / enable ability move slider by grabbing it with mouse or by touching it with finger (on touch screens) by assigning false / true to this property

    animating: boolean

    true if swiper is in transition

    autoplay: AutoplayMethods
    cardsEffect: CardsEffectMethods
    clickedIndex: number

    Index number of last clicked slide

    clickedSlide: HTMLElement

    Link to last clicked slide (HTMLElement)

    controller: ControllerMethods
    coverflowEffect: CoverflowEffectMethods
    creativeEffect: CreativeEffectMethods
    cubeEffect: CubeEffectMethods
    currentBreakpoint: any

    !INTERNAL

    destroyed: boolean

    !INTERNAL

    el: HTMLElement

    Slider container HTML element

    enabled: boolean

    true if Swiper is enabled, false otherwise

    fadeEffect: FadeEffectMethods
    flipEffect: FlipEffectMethods
    freeMode: FreeModeMethods
    hashNavigation: HashNavigationMethods
    height: number

    Height of container

    isBeginning: boolean

    true if slider on most "left"/"top" position

    isEnd: boolean

    true if slider on most "right"/"bottom" position

    isLocked: boolean

    true if slide is "locked" (by watchOverflow) and slides can not be, e.g. when amount of slides is less that slides per view

    keyboard: KeyboardMethods
    loopedSlides: number | null

    !INTERNAL

    modules: SwiperModule[]

    !INTERNAL

    mousewheel: MousewheelMethods
    navigation: NavigationMethods
    originalParams: SwiperOptions

    Object with original initialization parameters

    pagination: PaginationMethods
    parallax: ParallaxMethods

    Object with passed initialization parameters

    previousIndex: number

    Index number of previously active slide

    progress: number

    Current progress of wrapper translate (from 0 to 1)

    realIndex: number

    Index number of currently active slide considering rearranged slides in loop mode

    rtlTranslate: boolean

    !INTERNAL

    scrollbar: ScrollbarMethods
    slides: HTMLElement[]

    Array of slides HTML elements. To get specific slide HTMLElement use swiper.slides[1]

    slidesEl: HTMLElement

    Wrapper HTML element

    slidesGrid: number[]

    Slides grid

    slidesSizesGrid: number[]

    Array of widths for slides

    snapGrid: number[]

    Slides snap grid

    snapIndex: number

    Index number of current snap in snapGrid

    swipeDirection: "next" | "prev"

    Direction of sliding

    touches: {
        currentX: number;
        currentY: number;
        diff: number;
        startX: number;
        startY: number;
    }

    Object with the following touch event properties:

    • swiper.touches.startX
    • swiper.touches.startY
    • swiper.touches.currentX
    • swiper.touches.currentY
    • swiper.touches.diff
    translate: number

    Current value of wrapper translate

    width: number

    Width of container

    wrapperEl: HTMLElement

    Wrapper HTML element

    defaults: SwiperOptions

    Swiper default options

    extendedDefaults: SwiperOptions

    Object with global Swiper extended options

    Methods

    • Add new slides to the required index. slides could be HTMLElement or HTML string with new slide or array with such slides, for example:

      Parameters

      • index: number
      • slides: string | HTMLElement | string[] | HTMLElement[]

      Returns void

      addSlide(1, '<div class="swiper-slide">Slide 10"</div>')

      addSlide(1, [
      '<div class="swiper-slide">Slide 10"</div>',
      '<div class="swiper-slide">Slide 11"</div>'
      ]);
    • Add new slides to the end. slides could be HTMLElement or HTML string with new slide or array with such slides, for example:

      Parameters

      • slides: string | HTMLElement | string[] | HTMLElement[]

      Returns void

      appendSlide('<div class="swiper-slide">Slide 10"</div>')

      appendSlide([
      '<div class="swiper-slide">Slide 10"</div>',
      '<div class="swiper-slide">Slide 11"</div>'
      ]);
    • Attach all events listeners again

      Returns void

    • Changes slider direction from horizontal to vertical and back.

      Parameters

      • Optionaldirection: "horizontal" | "vertical"

        New direction. If not specified, then will automatically changed to opposite direction

      • OptionalneedUpdate: boolean

        Will call swiper.update(). Default true

      Returns void

    • Changes slider language

      Parameters

      • direction: "rtl" | "ltr"

        New direction. Should be rtl or ltr

      Returns void

    • Destroy slider instance and detach all events listeners

      Parameters

      • OptionaldeleteInstance: boolean

        Set it to false (by default it is true) to not to delete Swiper instance

      • OptionalcleanStyles: boolean

        Set it to true (by default it is true) and all custom styles will be removed from slides, wrapper and container. Useful if you need to destroy Swiper and to init again with new options or in different direction

      Returns void

    • Detach all events listeners

      Returns void

    • Disable Swiper (if it was enabled). When Swiper is disabled, it will hide all navigation elements and won't respond to any events and interactions

      Returns void

    • Fire event on instance

      Type Parameters

      Parameters

      • event: E
      • ...args: any[]

      Returns void

    • Enable Swiper (if it was disabled)

      Returns void

    • !INTERNAL

      Parameters

      Returns string

    • Get current value of swiper wrapper css3 transform translate

      Returns any

    • Initialize slider

      Parameters

      • Optionalel: HTMLElement

      Returns SwiperClass

    • !INTERNAL

      Returns boolean

    • !INTERNAL

      Returns void

    • !INTERNAL

      Returns void

    • Get current maximal translate value

      Returns number

    • Get current minimal translate value

      Returns number

    • Remove event handler

      Type Parameters

      Parameters

      Returns void

    • Remove all handlers for specified event

      Type Parameters

      Parameters

      • event: E

      Returns void

    • Remove event listener that will be fired on all events

      Parameters

      • handler: (eventName: string, ...args: any[]) => void

      Returns void

    • Add event listener that will be fired on all events

      Parameters

      • handler: (eventName: string, ...args: any[]) => void

      Returns void

    • Add event handler that will be removed after it was fired

      Type Parameters

      Parameters

      Returns void

    • Add new slides to the beginning. slides could be HTMLElement or HTML string with new slide or array with such slides, for example:

      Parameters

      • slides: string | HTMLElement | string[] | HTMLElement[]

      Returns void

      prependSlide('<div class="swiper-slide">Slide 0"</div>')

      prependSlide([
      '<div class="swiper-slide">Slide 1"</div>',
      '<div class="swiper-slide">Slide 2"</div>'
      ]);
    • Remove all slides

      Returns void

    • Remove selected slides. slideIndex could be a number with slide index to remove or array with indexes.

      Parameters

      • slideIndex: number | number[]

      Returns void

      removeSlide(0); // remove first slide
      removeSlide([0, 1]); // remove first and second slides
      removeAllSlides(); // Remove all slides
    • !INTERNAL

      Returns void

    • Set grab cursor

      Returns void

    • Set Swiper translate progress (from 0 to 1). Where 0 - its initial position (offset) on first slide, and 1 - its maximum position (offset) on last slide

      Parameters

      • progress: number

        Swiper translate progress (from 0 to 1).

      • Optionalspeed: number

        Transition duration (in ms).

      Returns void

    • Set custom css3 transform's translate value for swiper wrapper

      Parameters

      • translate: any

      Returns void

    • Run transition to next slide.

      Parameters

      • Optionalspeed: number

        Transition duration (in ms).

      • OptionalrunCallbacks: boolean

        Set it to false (by default it is true) and transition will not produce transition events.

      Returns boolean

    • Run transition to previous slide.

      Parameters

      • Optionalspeed: number

        Transition duration (in ms).

      • OptionalrunCallbacks: boolean

        Set it to false (by default it is true) and transition will not produce transition events.

      Returns boolean

    • Reset swiper position to currently active slide for the duration equal to 'speed' parameter.

      Parameters

      • Optionalspeed: number

        Transition duration (in ms).

      • OptionalrunCallbacks: boolean

        Set it to false (by default it is true) and transition will not produce transition events.

      Returns boolean

    • Get dynamically calculated amount of slides per view, useful only when slidesPerView set to auto

      Returns number

    • Run transition to the slide with index number equal to 'index' parameter for the duration equal to 'speed' parameter.

      Parameters

      • index: number

        Index number of slide.

      • Optionalspeed: number

        Transition duration (in ms).

      • OptionalrunCallbacks: boolean

        Set it to false (by default it is true) and transition will not produce transition events.

      Returns boolean

    • Reset swiper position to closest slide/snap point for the duration equal to 'speed' parameter.

      Parameters

      • Optionalspeed: number

        Transition duration (in ms).

      • OptionalrunCallbacks: boolean

        Set it to false (by default it is true) and transition will not produce transition events.

      Returns boolean

    • Does the same as .slideTo but for the case when used with enabled loop. So this method will slide to slides with realIndex matching to passed index

      Parameters

      • index: number

        Index number of slide.

      • Optionalspeed: number

        Transition duration (in ms).

      • OptionalrunCallbacks: boolean

        Set it to false (by default it is true) and transition will not produce transition events.

      Returns SwiperClass

    • Animate custom css3 transform's translate value for swiper wrapper

      Parameters

      • translate: number

        Translate value (in px)

      • speed: number

        Transition duration (in ms)

      • OptionalrunCallbacks: boolean

        Set it to false (by default it is true) and transition will not produce transition events

      • OptionaltranslateBounds: boolean

        Set it to false (by default it is true) and transition value can extend beyond min and max translate

      Returns any

    • Unset grab cursor

      Returns void

    • You should call it after you add/remove slides manually, or after you hide/show it, or do any custom DOM modifications with Swiper This method also includes subcall of the following methods which you can use separately:

      Returns void

    • Force swiper to update its height (when autoHeight enabled) for the duration equal to 'speed' parameter

      Parameters

      • Optionalspeed: number

        Transition duration (in ms).

      Returns void

    • recalculate swiper progress

      Returns void

    • recalculate size of swiper container

      Returns void

    • recalculate number of slides and their offsets. Useful after you add/remove slides with JavaScript

      Returns void

    • update active/prev/next classes on slides and bullets

      Returns void

    • Extend global Swiper defaults

      Parameters

      Returns void

    • Installs modules on Swiper in runtime.

      Parameters

      Returns void