Hello people i need your help,
Am using the Simple Slider [swiper] on my new project created with Bootstrap Studio, it works but when am trying to make it to autoplay then its not working, its goes to fast !!!
$[function[]{ // Initializing the swiper plugin for the slider. // Read more here: //idangero.us/swiper/api/ var mySwiper = new Swiper ['.swiper-container', { loop: true, pagination: '.swiper-pagination', paginationClickable: true, nextButton: '.swiper-button-next', prevButton: '.swiper-button-prev', autoplay: { delay: 5000, }, }]; }];How to fix this ?
I tried to change delay value but every value am setting is working wrong.. its working to fast.........
Am very disappointment......... can someone please help me to make the slider work normal !?
Thanks...
Remove
autoplay: { delay: 5000, },and add
autoplay: 4000There is a discussion here about it
Thanks a lot Windy, that solved the problem !
Slide 1 Slide 2 Slide 3 ...
Swiper package contains different sets of CSS, Less and SCSS styles: CSS styles for bundle version: CSS styles for bundle version [package imports]: CSS styles for core version and modules [package imports]: Less styles are separate styles for core version and modules [package imports]: SCSS styles are also separate styles for core version and modules [package imports]: Now, when we have Swiper's HTML, we need to initialize it using the following function: new Swiper[swiperContainer, parameters]- initialize swiper with options For example: After you initialize Swiper it is possible to access to Swiper's instance on its HTMLElement. It is swiper property of Swiper's HTML container element: Let's look on list of all available parameters: Set to false to disable swiping to next slide direction [to right or bottom] Set to false to disable swiping to previous slide direction [to left or top] If false, then the only way to switch the slide is use of external API functions like slidePrev or slideNext Set to true and slider wrapper will adapt its height to the height of the currently active slide Allows to set different parameter for different responsive breakpoints [screen sizes]. Not all parameters can be changed in breakpoints, only those which are not required different layout and logic, like slidesPerView, slidesPerGroup, spaceBetween, grid.rows. Such parameters like loop and effect won't work Base for breakpoints [beta]. Can be window or container. If set to window [by default] then breakpoint keys mean window width. If set to container then breakpoint keys treated as swiper container width Currently in beta and not supported by Swiper Angular, React, Svelte and Vue components When enabled it center slides if the amount of slides less than slidesPerView. Not intended to be used loop mode and grid.rows If true, then active slide will be centered, not always on the left side. If true, then active slide will be centered without adding gaps at the beginning and end of slider. Required centeredSlides: true. Not intended to be used with loop or pagination The beginning of the modifier CSS class that can be added to swiper container depending on different parameters When enabled Swiper will automatically wrap slides with swiper-wrapper element, and will create required elements for navigation, pagination and scrollbar they are enabled [with their respective params object or with boolean true]] When enabled it will use modern CSS Scroll Snap API. It doesn't support all of Swiper's features, but potentially should bring a much better performance in simple configurations. This is what is not supported when it is enabled: Can be 'horizontal' or 'vertical' [for vertical slider]. Enable to release Swiper events for swipe-back work in app. If set to 'prevent' then it will prevent system swipe-back navigation instead Area [in px] from left edge of the screen to release touch events for swipe-back in app Transition effect. Can be 'slide', 'fade', 'cube', 'coverflow', 'flip' or 'creative' Whether Swiper initially enabled. When Swiper is disabled, it will hide all navigation elements and won't respond to any events and interactions CSS selector for focusable elements. Swiping will be disabled on such elements if they are "focused" If disabled, then slider will be animated only when you release it, it will not move while you hold your finger on it This option may a little improve desktop usability. If true, user will see the "grab" cursor when hover on Swiper Swiper height [in px]. Parameter allows to force Swiper height. Useful only if you initialize Swiper when it is hidden and in SSR and Test environments for correct Swiper initialization Setting this parameter will make Swiper not responsive Whether Swiper should be initialised automatically when you create an instance. If disabled, then you need to init it manually by calling swiper.init[] Index number of initial slide. Set to false if you want to disable long swipes Minimal duration [in ms] to trigger swipe to next/previous slide during long swipes Ratio to trigger swipe to next/previous slide during long swipes Set to true to enable continuous loop mode Because of nature of how the loop mode works, it will add duplicated slides. Such duplicated slides will have additional classes: If you use it along with slidesPerView: 'auto' then you need to specify loopedSlides parameter with amount of slides to loop [duplicate]. Should not be used together with rewind mode Addition number of slides that will be cloned after creating of loop Enable and loop mode will fill groups with insufficient number of slides with blank slides. Good to be used with slidesPerGroup parameter When enabled it prevents Swiper slide prev/next transitions when transitions is already in progress [has effect when loop enabled] If you use slidesPerView:'auto' with loop mode you should tell to Swiper how many slides it should loop [duplicate] using this parameter If total number of slides less than specified here value, then Swiper will enable backface-visibility: hidden on slide elements to reduce visual "flicker" in Safari. It is not recommended to enable it on large amount of slides as it will reduce performance Array with Swiper modules Set to true on Swiper for correct touch events interception. Use only on swipers that use same direction as the parent one Enable/disable swiping on elements matched to class specified in noSwipingClass Specify noSwiping's element css class Can be used instead of noSwipingClass to specify elements to disable swiping on. For example 'input' will disable swiping on all inputs Normalize slide index. Set to true if you also need to watch Mutations for Swiper parent elements Set to true if you also need to watch Mutations for Swiper slide children elements Set to true to enable Mutation Observer on Swiper and its elements. In this case Swiper will be updated [reinitialized] each time if you change its style [like hide/show] or modify its child elements [like adding/removing slides] Register event handlers Passive event listeners will be used by default where possible to improve scrolling performance on mobile devices. But if you need to use e.preventDefault and you have conflict with it, then you should disable this parameter When enabled Swiper will force to load all images Set to true to prevent accidental unwanted clicks on links during swiping Set to true to stop clicks event propagation on links during swiping When enabled it won't allow to change slides by swiping or navigation/pagination buttons during transition Set to false if you want to disable resistant bounds This option allows you to control resistance ratio When enabled it will use ResizeObserver [if supported by browser] on swiper container to detect container resize [instead of watching for window resize] Set to true to enable "rewind" mode. When enabled, clicking "next" navigation button [or calling .slideNext[]] when on last slide will slide back to the first slide. Clicking "prev" navigation button [or calling .slidePrev[]] when on first slide will slide forward to the last slide. Should not be used together with loop mode Set to true to round values of slides width and height to prevent blurry texts on usual resolution screens [if you have such] Fire Transition/SlideChange/Start/End events on swiper initialization. Such events will be fired on initialization in case of your initialSlide is not 0, or you use loop mode Enabled this option and plugin will set width/height on swiper wrapper equal to total size of all slides. Mostly should be used as compatibility fallback option for browser that don't support flexbox layout well Set to false if you want to disable short swipes If true, Swiper will accept mouse events like touch events [click and drag to change slides] CSS class name of currently active slide By changing classes you will also need to change Swiper's CSS to reflect changed classes Not supported in Swiper Angular/React/Svelte/Vue components CSS class name of blank slide append to fill groups in loop mode when loopFillGroupWithBlank is also enabled By changing classes you will also need to change Swiper's CSS to reflect changed classes Not supported in Swiper Angular/React/Svelte/Vue CSS class name of slide By changing classes you will also need to change Swiper's CSS to reflect changed classes Not supported in Swiper Angular/React/Svelte/Vue components CSS class name of duplicated slide which represents the currently active slide By changing classes you will also need to change Swiper's CSS to reflect changed classes Not supported in Swiper Angular/React/Svelte/Vue components CSS class name of slide duplicated by loop mode By changing classes you will also need to change Swiper's CSS to reflect changed classes Not supported in Swiper Angular/React/Svelte/Vue CSS class name of duplicated slide which represents the slide next to active slide By changing classes you will also need to change Swiper's CSS to reflect changed classes Not supported in Swiper Angular/React/Svelte/Vue CSS class name of duplicated slide which represents the slide previous to active slide By changing classes you will also need to change Swiper's CSS to reflect changed classes Not supported in Swiper Angular/React/Svelte/Vue CSS class name of slide which is right after currently active slide By changing classes you will also need to change Swiper's CSS to reflect changed classes Not supported in Swiper Angular/React/Svelte/Vue CSS class name of slide which is right before currently active slide By changing classes you will also need to change Swiper's CSS to reflect changed classes Not supported in Swiper Angular/React/Svelte/Vue Set to true and click on any slide will produce transition to this slide CSS class name of currently visible slide By changing classes you will also need to change Swiper's CSS to reflect changed classes Not supported in Swiper Angular/React/Svelte/Vue Add [in px] additional slide offset in the end of the container [after all slides] Add [in px] additional slide offset in the beginning of the container [before all slides] Set numbers of slides to define and enable group sliding. Useful to use with slidesPerView > 1 This param intended to be used only with slidesPerView: 'auto' and slidesPerGroup: 1. When enabled, it will skip all slides in view on .slideNext[] & .slidePrev[] methods calls, on Navigation "buttons" clicks and in autoplay. The parameter works in the following way: If slidesPerGroupSkip equals 0 [default], no slides are excluded from grouping, and the resulting behaviour is the same as without this change. If slidesPerGroupSkip is equal or greater than 1 the first X slides are treated as single groups, whereas all following slides are grouped by the slidesPerGroup value. Number of slides per view [slides visible at the same time on slider's container]. If you use it with "auto" value and along with loop: true then you need to specify loopedSlides parameter with amount of slides to loop [duplicate] slidesPerView: 'auto' is currently not compatible with multirow mode, when grid.rows > 1 Distance between slides in px. If you use "margin" css property to the elements which go into Swiper in which you pass "spaceBetween" into, navigation might not work properly. Duration of transition between slides [in ms] String with CSS selector or HTML element of the container with pagination that will work as only available handler for swiping Threshold value in px. If "touch distance" will be lower than this value then swiper will not move Allowable angle [in degrees] to trigger touch move Target element to listen touch events on. Can be 'container' [to listen for touch events on swiper] or 'wrapper'[to listen for touch events on swiper-wrapper] If enabled, then propagation of "touchmove" will be stopped Touch ratio Enable to release touch events on slider edge position [beginning, end] to allow for further page scrolling Force to always prevent default for touchstart [pointerdown] event If disabled, touchstart [pointerdown] event won't be prevented If enabled [by default] and navigation elements' parameters passed as a string [like ".pagination"] then Swiper will look for such elements through child elements first. Applies for pagination, prev/next buttons and scrollbar elements When enabled Swiper will be reinitialized after all inner images [ tags] are loaded. Required preloadImages: true Swiper will recalculate slides position on window resize [orientationchange] Required for active slide detection when rendered on server-side and enabled history userAgent string. Required for browser/device detection when rendered on server-side Enabled this option and swiper will be operated as usual except it will not move, real translate values on wrapper will not be set. Useful when you may need to create custom slide transition When enabled Swiper will be disabled and hide navigation buttons on case there are not enough slides for sliding. Enable this feature to calculate each slides progress and visibility [slides in viewport will have additional visible class] Swiper width [in px]. Parameter allows to force Swiper width. Useful only if you initialize Swiper when it is hidden and in SSR and Test environments for correct Swiper initialization Setting this parameter will make Swiper not responsive CSS class name of slides' wrapper By changing classes you will also need to change Swiper's CSS to reflect changed classes Not supported in Swiper Angular/React/Svelte/Vue Add event listener that will be fired on all events After we initialize Slider we have its initialized instance in variable [like swiper variable in example above] with helpful methods and properties: Dom7 element with slider container HTML element. To get vanilla HTMLElement use swiper.el Dom7 element with slider wrapper HTML element. To get vanilla HTMLElement use swiper.wrapperEl Index number of currently active slide Note, that in loop mode active index value will be always shifted on a number of looped/duplicated slides Disable / enable ability to slide to the next slides by assigning false / true to this property Disable / enable ability to slide to the previous slides by assigning false / true to this property 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 true if swiper is in transition Index number of last clicked slide Link to last clicked slide [HTMLElement] Slider container HTML element Height of container true if slider on most "left"/"top" position true if slider on most "right"/"bottom" position Object with original initialization parameters Object with passed initialization parameters Index number of previously active slide Current progress of wrapper translate [from 0 to 1] Index number of currently active slide considering duplicated slides in loop mode Dom7 array-like collection of slides HTML elements. To get specific slide HTMLElement use swiper.slides[1] Object with the following touch event properties: Current value of wrapper translate Width of container Wrapper HTML element Swiper default options Object with global Swiper extended options Attach all events listeners again Changes slider direction from horizontal to vertical and back. Destroy slider instance and detach all events listeners Detach all events listeners 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 Fire event on instance Enable Swiper [if it was disabled] Get current value of swiper wrapper css3 transform translate Initialize slider !INTERNAL !INTERNAL Remove event handler Remove event listener that will be fired on all events Add event handler Add event listener that will be fired on all events Add event handler that will be removed after it was fired Set grab cursor 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 Set custom css3 transform's translate value for swiper wrapper Run transition to next slide. Run transition to previous slide. Reset swiper position to currently active slide for the duration equal to 'speed' parameter. Run transition to the slide with index number equal to 'index' parameter for the duration equal to 'speed' parameter. Reset swiper position to closest slide/snap point for the duration equal to 'speed' parameter. 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 Animate custom css3 transform's translate value for swiper wrapper Unset grab cursor 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: Force swiper to update its height [when autoHeight enabled] for the duration equal to 'speed' parameter recalculate swiper progress recalculate size of swiper container recalculate number of slides and their offsets. Useful after you add/remove slides with JavaScript update active/prev/next classes on slides and bullets Extend global Swiper defaults Installs modules on Swiper in runtime. Swiper comes with a bunch of useful events you can listen. Events can be assigned in two ways: Using on parameter on swiper initialization: Using on method after swiper initialization. Please note, that this keyword within event handler always points to Swiper instance Event will fired on active index change Event will fired right after initialization Event will be fired right before Swiper destroyed Event will fired right before initialization Event will be fired right before "loop fix" Event will fired before resize handler Event will fired before slide change transition start Event will fired before transition start Event will be fired on breakpoint change Event will fired on direction change Event will be fired when user click/tap on Swiper. Receives touchend event as an arguments. Event will be fired on swiper destroy Event will be fired when user double click/tap on Swiper Event will be fired when user double tap on Swiper's container. Receives touchend event as an arguments Event will be fired when Swiper goes from beginning or end position Event will be fired right after all inner images are loaded. updateOnImagesReady should be also enabled Fired right after Swiper initialization. Event will be fired when swiper is locked [when watchOverflow enabled] Event will be fired after "loop fix" Event will be fired on momentum bounce Event will be fired if observer is enabled and it detects DOM mutations Event will be fired on orientation change [e.g. landscape -> portrait] Event will be fired when Swiper progress is changed, as an arguments it receives progress that is always from 0 to 1 Event will be fired when Swiper reach its beginning [initial position] Event will be fired when Swiper reach last slide Event will fired on real index change Event will be fired on window resize right before swiper's onresize manipulation Event will be fired everytime when swiper starts animation. Receives current transition duration [in ms] as an arguments Event will be fired when swiper's wrapper change its position. Receives current translate value as an arguments Event will be fired when currently active slide is changed Event will be fired after animation to other slide [next or previous]. Event will be fired in the beginning of animation to other slide [next or previous]. Same as "slideChangeTransitionEnd" but for "forward" direction only Same as "slideChangeTransitionStart" but for "forward" direction only Same as "slideChangeTransitionEnd" but for "backward" direction only Same as "slideChangeTransitionStart" but for "backward" direction only Event will be fired in the end of animation of resetting slide to current one Event will be fired in the beginning of animation of resetting slide to current one Event will be fired with first touch/drag move Event will be fired when user touch and move finger over Swiper and move it. Receives touchmove event as an arguments. Event will be fired when slides grid has changed Event will be fired when number of slides has changed Event will be fired when snap grid has changed Event will fired on snap index change Event will be fired when user click/tap on Swiper. Receives touchend event as an arguments. Event will be fired when Swiper goes to beginning or end position Event will be fired when user release Swiper. Receives touchend event as an arguments. Event will be fired when user touch and move finger over Swiper. Receives touchmove event as an arguments. Event will be fired when user touch and move finger over Swiper in direction opposite to direction parameter. Receives touchmove event as an arguments. Event will be fired when user touch Swiper. Receives touchstart event as an arguments. Event will be fired after transition. Event will be fired in the beginning of transition. Event will be fired when swiper is unlocked [when watchOverflow enabled] Event will be fired after swiper.update[] call Object with navigation parameters or boolean true to enable with default settings. CSS class name added to navigation button when it becomes disabled CSS class name added to navigation button when it becomes hidden Toggle navigation buttons visibility after click on Slider's container CSS class name added to navigation button when it is disabled String with CSS selector or HTML element of the element that will work like "next" button after click on it String with CSS selector or HTML element of the element that will work like "prev" button after click on it Event will be fired on navigation hide Event will be fired on navigation show Object with pagination parameters or boolean true to enable with default settings. CSS class name of currently active pagination bullet CSS class name of single pagination bullet Defines which HTML tag will be used to represent single pagination bullet. Only for 'bullets' pagination type. If true then clicking on pagination button will cause transition to appropriate slide. Only for bullets pagination type CSS class name set to pagination when it is clickable CSS class name of the element with currently active index in "fraction" pagination Good to enable if you use bullets pagination with a lot of slides. So it will keep only few bullets visible at the same time. The number of main bullets visible when dynamicBullets enabled. String with CSS selector or HTML element of the container with pagination CSS class name of pagination when it becomes inactive Toggle [hide/show] pagination container visibility after click on Slider's container CSS class name set to pagination in horizontal Swiper CSS class name set to pagination when it is disabled The beginning of the modifier CSS class name that will be added to pagination depending on parameters CSS class name of pagination progressbar fill element Makes pagination progressbar opposite to Swiper's direction parameter, means vertical progressbar for horizontal swiper direction and horizontal progressbar for vertical swiper direction CSS class name of pagination progressbar opposite CSS class name of the element with total number of "snaps" in "fraction" pagination String with type of pagination. Can be 'bullets', 'fraction', 'progressbar' or 'custom' CSS class name set to pagination in vertical Swiper Event will be fired on pagination hide Event will be fired after pagination rendered Event will be fired on pagination show Event will be fired when pagination updated Object with scrollbar parameters or boolean true to enable with default settings. Scrollbar draggable element CSS class Size of scrollbar draggable element in px Set to true to enable make scrollbar draggable that allows you to control slider position String with CSS selector or HTML element of the container with scrollbar. Hide scrollbar automatically after user interaction Scrollbar element additional CSS class when it is disabled Set to true to snap slider position to slides when you release scrollbar Event will be fired on draggable scrollbar drag end Event will be fired on draggable scrollbar drag move Event will be fired on draggable scrollbar drag start Object with autoplay parameters or boolean true to enable with default settings Delay between transitions [in ms]. If this parameter is not specified, auto play will be disabled If you need to specify different delay for specific slides you can do it by usingdata-swiper-autoplay [in ms] attribute on slide. Set to false and autoplay will not be disabled after user interactions [swipes], it will be restarted every time after interaction When enabled autoplay will be paused on mouse enter over Swiper container. If disableOnInteraction is also enabled, it will stop autoplay instead of pause Enables autoplay in reverse direction Enable this parameter and autoplay will be stopped when it reaches last slide [has no effect in loop mode] When enabled autoplay will wait for wrapper transition to continue. Can be disabled in case of using Virtual Translate when your slider may not have transition Event will be fired when slide changed with autoplay Event will be fired on autoplay pause [on mouse/pointer enter], when pauseOnMouseEnter enabled Event will be fired on autoplay resume [on mouse/pointer leave], when pauseOnMouseEnter enabled Event will be fired in when autoplay started Event will be fired when autoplay stopped Enables free mode functionality. Object with free mode parameters or boolean true to enable with default settings. Minimum touchmove-velocity required to trigger free mode momentum If enabled, then slide will keep moving for a while after you release it Set to false if you want to disable momentum bounce in free mode Higher value produces larger momentum bounce effect Higher value produces larger momentum distance after you release slider Higher value produces larger momentum velocity after you release slider Set to enabled to enable snap to slides positions in free mode Object with grid parameters to enable "multirow" slider. Can be 'column' or 'row'. Defines how slides should fill rows, by column or by row Number of slides rows, for multirow layout rows > 1 is currently not compatible with loop mode [loop: true] Manipulation module adds useful Swiper methods to manipulate slides. It makes sense to use it only with Swiper Core version, not intended to be uses with Swiper Angular, React, Svelte or Vue. Add new slides to the required index. slides could be HTMLElement or HTML string with new slide or array with such slides, for example: Add new slides to the end. slides could be HTMLElement or HTML string with new slide or array with such slides, for example: Add new slides to the beginning. slides could be HTMLElement or HTML string with new slide or array with such slides, for example: Remove all slides Remove selected slides. slideIndex could be a number with slide index to remove or array with indexes. Swiper supports parallax transition effects for swiper/slides nested elements. There are two types of parallax elements supported: To enable parallax effects you need to init Swiper with passed parallax:true parameter and add one of the following [or mix] attributes to required elements: Object with parallax parameters or boolean true to enable with default settings. Enable, if you want to use "parallaxed" elements inside of slider To enable lazy loading, first of all we need a special layout for images or elements with background in slides: As you see: You may also add animated preloader spinner to slide which will be removed automatically after image loaded: Or white one for dark layout: After that we need to enable lazy loading on Swiper initialization: If you use slidesPerView: 'auto' or slidesPerView > 1, then you should also enable watchSlidesProgress and Swiper will load images in currently visible slides Enables images lazy loading. Object with lazy loading parameters or boolean true to enable with default settings Enables to check is the Swiper in view before lazy loading images on initial slides CSS class name of lazy element Whether the lazy loading images is enabled By default, Swiper will load lazy images after transition to this slide, so you may enable this parameter if you need it to start loading of new image in the beginning of transition Set to true to enable lazy loading for the closest slides images [for previous and next slide images] Amount of next/prev slides to preload lazy images in. Can't be less than slidesPerView CSS class name of lazy loaded element CSS class name of lazy loading element CSS class name of lazy preloader Element to check scrolling on for checkInView. Defaults to window Event will be fired in the beginning of lazy loading of image Event will be fired when lazy loading image will be loaded Be sure to have the effect param set to 'fade' in order for this to work. Note that crossFade should be set to true in order to avoid seeing content behind or underneath. Object with Fade-effect parameters Enables slides cross fade CSS selector of the element inside of the slide to transform instead of the slide itself. Useful to use with cssMode Be sure to have the effect param set to 'coverflow' in order for this to work. Object with Coverflow-effect parameters. Depth offset in px [slides translate in Z axis] Effect multiplier Slide rotate in degrees Slide scale effect Enables slides shadows Stretch space between slides [in px] CSS selector of the element inside of the slide to transform instead of the slide itself. Useful to use with cssMode Be sure to have the effect param set to 'flip' in order for this to work. Object with Flip-effect parameters Limit edge slides rotation Enables slides shadows CSS selector of the element inside of the slide to transform instead of the slide itself. Useful to use with cssMode Be sure to have the effect param set to 'cube' in order for this to work. Object with Cube-effect parameters Enables main slider shadow Main shadow offset in px Main shadow scale ratio Enables slides shadows Be sure to have the effect param set to 'cards' in order for this to work. Object with Cards-effect parameters Enables slides shadows CSS selector of the element inside of the slide to transform instead of the slide itself. Useful to use with cssMode Be sure to have the effect param set to 'creative' in order for this to work. Object with Creative-effect parameters Limit progress/offset to amount of side slides. If 1, then slides all slides after prev/next will have same state. If 2, then all slides after 2nd before/after active will have same state, etc. Next slide transformations. Enable this parameter if your custom transforms require 3D transformations [translateZ, rotateX, rotateY ] Previous slide transformations. Accepts object of the following type: Allows to multiply slides transformations and opacity. Splits shadow "opacity" per slide based on limitProgress [only if transformation shadows enabled]. E.g. setting limitProgress: 2 and enabling shadowPerProgress, will set shadow opacity to 0.5 and 1 on two slides next to active. With this parameter disabled, all slides beside active will have shadow with 1 opacity CSS selector of the element inside of the slide to transform instead of the slide itself. Useful to use with cssMode In addition to Controller component Swiper comes with Thumbs component that is designed to work with additional thumbs swiper in a more correct way than Controller which is used for syncing two swipers. Object with thumbs component parameters Allows to set on which thumbs active slide from edge it should automatically move scroll thumbs. For example, if set to 1 and last visible thumb will be activated [1 from edge] it will auto scroll thumbs When enabled multiple thumbnail slides may get activated Additional class that will be added to activated thumbs swiper slide Swiper instance of swiper used as thumbs or object with Swiper parameters to initialize thumbs swiper Additional class that will be added to thumbs swiper Swiper supports zoom images functionality [similar to what you see on iOS when browsing single photo] where you can zoom-in image by pinch gesture and or by zoom-in/out by double tap on it. In this case, additional layout is required: All "zoomable" images should be wrapped with the div with swiper-zoom-container class. By default it expects to zoom one of the img, picture or canvas element. If you want to make zoom on some other custom element, then just add swiper-zoom-target class to this element. For example: You can override maxRatio parameter for specific slides by using data-swiper-zoom attribute on zoom container. Enables zooming functionality. Object with zoom parameters or boolean true to enable with default settings CSS class name of zoom container Maximum image zoom multiplier Minimal image zoom multiplier Enable/disable zoom-in by slide's double tap CSS class name of zoomed in container Event will be fired on zoom change Enables navigation through slides using keyboard. Object with keyboard parameters or boolean true to enable with default settings Set to true to enable keyboard control When enabled it will control sliders that are currently in viewport When enabled it will enable keyboard navigation by Page Up and Page Down keys Event will be fired on key press Enables navigation through slides using mouse wheel. Object with mousewheel parameters or boolean true to enable with default settings String with CSS selector or HTML element of the container accepting mousewheel events. By default it is swiper Set to true to force mousewheel swipes to axis. So in horizontal mode mousewheel will work only with horizontal mousewheel scrolling, and only with vertical scrolling in vertical mode. Set to true to invert sliding direction Set to true and swiper will release mousewheel event and allow page scrolling when swiper is on edge positions [in the beginning or in the end] Multiplier of mousewheel data, allows to tweak mouse wheel sensitivity Minimum mousewheel scroll delta to trigger swiper slide change Minimum mousewheel scroll time delta [in ms] to trigger swiper slide change Event will be fired on mousewheel scroll Virtual Slides module allows to keep just required amount of slides in DOM. It is very useful in terms in performance and memory issues if you have a lot of slides, especially slides with heavyweight DOM tree or images. Note that according to Virtual Slides realization it doesn't work with loop mode, slidesPerColumn more than 1 and slidesPerView: 'auto' Enables virtual slides functionality. Object with virtual slides parameters or boolean true to enable with default settings. Increases amount of pre-rendered slides after active slide Increases amount of pre-rendered slides before active slide Enables DOM cache of rendering slides html elements. Once they are rendered they will be saved to cache and reused from it. When enabled [by default] it will update Swiper layout right after renderExternal called. Useful to disable and update swiper manually when used with render libraries that renders asynchronously Array with slides Hash navigation is intended to have a link to specific slide that allows to load page with specific slide opened. To make it work, you need to enable it by passing hashNavigation:true parameter and adding slides hashes in data-hash attribute: Enables hash url navigation to for slides. Object with hash navigation parameters or boolean true to enable with default settings Works in addition to hashnav to replace current url state with the new one instead of adding it to history Set to true to enable also navigation through slides [when hashnav is enabled] by browser history or by setting directly hash on document location Event will be fired on window hash change Event will be fired when swiper updates the hash Enables history push state where every slide will have its own url. In this parameter you have to specify main slides url like "slides" and specify every slide url using data-history attribute. Object with history navigation parameters or boolean true to enable with default settings Url key for slides Works in addition to hashnav or history to replace current url state with the new one instead of adding it to history Swiper page root, useful to specify when you use Swiper history mode not on root website page. For example can be //my-website.com/ or //my-website.com/subpage/ or /subpage/ Object with controller parameters or boolean true to enable with default settings Defines a way how to control another slider: slide by slide [with respect to other slider's grid] or depending on all slides/container [depending on total slider percentage]. Pass here another Swiper instance or array with Swiper instances that should be controlled by this Swiper Set to true and controlling will be in inverse direction Pass here another Swiper instance or array with Swiper instances that should be controlled by this Swiper Object with a11y parameters or boolean true to enable with default settings. Message for screen readers for outer swiper container Message for screen readers describing the role of outer swiper container Enables A11y Message for screen readers for previous button when swiper is on first slide Message for screen readers describing the role of slide element Message for screen readers for next button when swiper is on last slide Message for screen readers for next button CSS class name of A11y notification Message for screen readers for single pagination bullet Message for screen readers for previous button Message for screen readers describing the label of slide element Value of swiper slide role attribute You have two options of making custom version of Swiper. If you use bundler with JS modules support in your project you can import only the modules you need: The following modules are exported: Swiper comes with gulp builder that allows to build custom library version where you may include only required modules. We need the following: Download and unzip Swiper GitHub repository to local folder Install Node.js [if not installed] Now, we need to install required dependencies. Go to the folder with downloaded and unzipped Swiper repository and execute in terminal: Open scripts/build-config.js file: Now, we are ready to build custom version of Swiper: That is all. Generated CSS and JS files and their minified versions will be available in dist/ folder. Swiper is fully typed, it exports Swiper and SwiperOptions types: You can also check auto generated TypeScript definitions explorer for all the types, options, properties and methods.CSS Styles
Less Styles
SCSS Styles
NameTypeDefaultDescription allowSlideNext boolean true allowSlidePrev boolean true allowTouchMove boolean true autoHeight boolean false breakpoints object breakpointsBase string 'window' centerInsufficientSlides boolean false centeredSlides boolean false centeredSlidesBounds boolean false containerModifierClass string 'swiper-' createElements boolean false cssMode boolean false direction 'horizontal' | 'vertical' 'horizontal' edgeSwipeDetection string | boolean false edgeSwipeThreshold number 20 effect 'slide' | 'fade' | 'cube' | 'coverflow' | 'flip' | 'creative' | 'cards' 'slide' enabled boolean true focusableElements string 'input, select, option, textarea, button, video, label' followFinger boolean true grabCursor boolean false height null | number null init boolean true initialSlide number 0 longSwipes boolean true longSwipesMs number 300 longSwipesRatio number 0.5 loop boolean false loopAdditionalSlides number 0 loopFillGroupWithBlank boolean false loopPreventsSlide boolean true loopedSlides null | number null maxBackfaceHiddenSlides number 10 modules SwiperModule[] nested boolean false noSwiping boolean true noSwipingClass string 'swiper-no-swiping' noSwipingSelector string normalizeSlideIndex boolean true observeParents boolean false observeSlideChildren boolean false observer boolean false on object passiveListeners boolean true preloadImages boolean true preventClicks boolean true preventClicksPropagation boolean true preventInteractionOnTransition boolean false resistance boolean true resistanceRatio number 0.85 resizeObserver boolean true rewind boolean false roundLengths boolean false runCallbacksOnInit boolean true setWrapperSize boolean false shortSwipes boolean true simulateTouch boolean true slideActiveClass string 'swiper-slide-active' slideBlankClass string 'swiper-slide-invisible-blank' slideClass string 'swiper-slide' slideDuplicateActiveClass string 'swiper-slide-duplicate-active' slideDuplicateClass string 'swiper-slide-duplicate' slideDuplicateNextClass string 'swiper-slide-duplicate-next' slideDuplicatePrevClass string 'swiper-slide-duplicate-prev' slideNextClass string 'swiper-slide-next' slidePrevClass string 'swiper-slide-prev' slideToClickedSlide boolean false slideVisibleClass string 'swiper-slide-visible' slidesOffsetAfter number 0 slidesOffsetBefore number 0 slidesPerGroup number 1 slidesPerGroupAuto boolean false slidesPerGroupSkip number 0 slidesPerView number | 'auto' 1 spaceBetween number 0 speed number 300 swipeHandler null | CSSSelector | HTMLElement null threshold number 0 touchAngle number 45 touchEventsTarget 'container' | 'wrapper' 'wrapper' touchMoveStopPropagation boolean false touchRatio number 1 touchReleaseOnEdges boolean false touchStartForcePreventDefault boolean false touchStartPreventDefault boolean true uniqueNavElements boolean true updateOnImagesReady boolean true updateOnWindowResize boolean true url null | string null userAgent null | string null virtualTranslate boolean false watchOverflow boolean true watchSlidesProgress boolean false width null | number null wrapperClass string 'swiper-wrapper' onAny function Properties swiper.$el Dom7Array swiper.$wrapperEl Dom7Array swiper.activeIndex number swiper.allowSlideNext boolean swiper.allowSlidePrev boolean swiper.allowTouchMove boolean swiper.animating boolean swiper.clickedIndex number swiper.clickedSlide HTMLElement swiper.el HTMLElement swiper.height number swiper.isBeginning boolean swiper.isEnd boolean swiper.originalParams SwiperOptions swiper.params SwiperOptions swiper.previousIndex number swiper.progress number swiper.realIndex number swiper.slides Dom7Array swiper.touches object swiper.translate number swiper.width number swiper.wrapperEl HTMLElement swiper.defaults SwiperOptions swiper.extendedDefaults SwiperOptions Methods swiper.attachEvents[] swiper.changeDirection[direction, needUpdate] swiper.destroy[deleteInstance, cleanStyles] swiper.detachEvents[] swiper.disable[] swiper.emit[event, args] swiper.enable[] swiper.getTranslate[] swiper.init[el] swiper.loopCreate[] swiper.loopDestroy[] swiper.off[event, handler] swiper.offAny[handler] swiper.on[event, handler] swiper.onAny[handler] swiper.once[event, handler] swiper.setGrabCursor[] swiper.setProgress[progress, speed] swiper.setTranslate[translate] swiper.slideNext[speed, runCallbacks] swiper.slidePrev[speed, runCallbacks] swiper.slideReset[speed, runCallbacks] swiper.slideTo[index, speed, runCallbacks] swiper.slideToClosest[speed, runCallbacks] swiper.slideToLoop[index, speed, runCallbacks] swiper.translateTo[translate, speed, runCallbacks, translateBounds] swiper.unsetGrabCursor[] swiper.update[] swiper.updateAutoHeight[speed] swiper.updateProgress[] swiper.updateSize[] swiper.updateSlides[] swiper.updateSlidesClasses[] swiper.extendDefaults[options] swiper.use[modules] NameArgumentsDescription activeIndexChange [swiper] afterInit [swiper] beforeDestroy [swiper] beforeInit [swiper] beforeLoopFix [swiper] beforeResize [swiper] beforeSlideChangeStart [swiper] beforeTransitionStart [swiper, speed, internal] breakpoint [swiper, breakpointParams] changeDirection [swiper] click [swiper, event] destroy [swiper] doubleClick [swiper, event] doubleTap [swiper, event] fromEdge [swiper] imagesReady [swiper] init [swiper] lock [swiper] loopFix [swiper] momentumBounce [swiper] observerUpdate [swiper] orientationchange [swiper] progress [swiper, progress] reachBeginning [swiper] reachEnd [swiper] realIndexChange [swiper] resize [swiper] setTransition [swiper, transition] setTranslate [swiper, translate] slideChange [swiper] slideChangeTransitionEnd [swiper] slideChangeTransitionStart [swiper] slideNextTransitionEnd [swiper] slideNextTransitionStart [swiper] slidePrevTransitionEnd [swiper] slidePrevTransitionStart [swiper] slideResetTransitionEnd [swiper] slideResetTransitionStart [swiper] sliderFirstMove [swiper, event] sliderMove [swiper, event] slidesGridLengthChange [swiper] slidesLengthChange [swiper] snapGridLengthChange [swiper] snapIndexChange [swiper] tap [swiper, event] toEdge [swiper] touchEnd [swiper, event] touchMove [swiper, event] touchMoveOpposite [swiper, event] touchStart [swiper, event] transitionEnd [swiper] transitionStart [swiper] unlock [swiper] update [swiper] NameTypeDefaultDescription navigation boolean | NavigationOptions { disabledClass string 'swiper-button-disabled' hiddenClass string 'swiper-button-hidden' hideOnClick boolean false lockClass string 'swiper-button-lock' nextEl null | CSSSelector | HTMLElement null prevEl null | CSSSelector | HTMLElement null } NameArgumentsDescription navigationHide [swiper] navigationShow [swiper] NameTypeDefaultDescription pagination boolean | PaginationOptions { bulletActiveClass string 'swiper-pagination-bullet-active' bulletClass string 'swiper-pagination-bullet' bulletElement string 'span' clickable boolean false clickableClass string 'swiper-pagination-clickable' currentClass string 'swiper-pagination-current' dynamicBullets boolean false dynamicMainBullets number 1 el null | CSSSelector | HTMLElement null formatFractionCurrent function[number] formatFractionTotal function[number] hiddenClass string 'swiper-pagination-hidden' hideOnClick boolean true horizontalClass string 'swiper-pagination-horizontal' lockClass string 'swiper-pagination-lock' modifierClass string 'swiper-pagination-' progressbarFillClass string 'swiper-pagination-progressbar-fill' progressbarOpposite boolean false progressbarOppositeClass string 'swiper-pagination-progressbar-opposite' renderBullet function[index, className] renderCustom function[swiper, current, total] renderFraction function[currentClass, totalClass] renderProgressbar function[progressbarFillClass] totalClass string 'swiper-pagination-total' type 'bullets' | 'fraction' | 'progressbar' | 'custom' 'bullets' verticalClass string 'swiper-pagination-vertical' } NameArgumentsDescription paginationHide [swiper] paginationRender [swiper, paginationEl] paginationShow [swiper] paginationUpdate [swiper, paginationEl] NameTypeDefaultDescription scrollbar boolean | ScrollbarOptions { dragClass string 'swiper-scrollbar-drag' dragSize number | 'auto' 'auto' draggable boolean false el null | CSSSelector | HTMLElement null hide boolean true lockClass string 'swiper-scrollbar-lock' snapOnRelease boolean false } NameArgumentsDescription scrollbarDragEnd [swiper, event] scrollbarDragMove [swiper, event] scrollbarDragStart [swiper, event] NameTypeDefaultDescription autoplay boolean | AutoplayOptions { delay number 3000 disableOnInteraction boolean true pauseOnMouseEnter boolean false reverseDirection boolean false stopOnLastSlide boolean false waitForTransition boolean true } NameArgumentsDescription autoplay [swiper] autoplayPause [swiper] autoplayResume [swiper] autoplayStart [swiper] autoplayStop [swiper] NameTypeDefaultDescription freeMode boolean | FreeModeOptions { enabled boolean minimumVelocity number 0.02 momentum boolean true momentumBounce boolean true momentumBounceRatio number 1 momentumRatio number 1 momentumVelocityRatio number 1 sticky boolean false } NameTypeDefaultDescription grid GridOptions { fill 'row' | 'column' 'column' rows number 1 } Manipulation Methods
Methods swiper.addSlide[index, slides] swiper.appendSlide[slides] swiper.prependSlide[slides] swiper.removeAllSlides[] swiper.removeSlide[slideIndex]
Slide 1 Subtitle Lorem ipsum dolor sit amet, ... I will change opacity I will change scale ...
Parallax Parameters
NameTypeDefaultDescription parallax boolean | ParallaxOptions { enabled boolean false } NameTypeDefaultDescription lazy boolean | LazyOptions { checkInView boolean false elementClass string 'swiper-lazy' enabled boolean loadOnTransitionStart boolean false loadPrevNext boolean false loadPrevNextAmount number 1 loadedClass string 'swiper-lazy-loaded' loadingClass string 'swiper-lazy-loading' preloaderClass string 'swiper-lazy-preloader' scrollingElement null | CSSSelector | HTMLElement | Dom7Array } NameArgumentsDescription lazyImageLoad [swiper, slideEl, imageEl] lazyImageReady [swiper, slideEl, imageEl] NameTypeDefaultDescription fadeEffect FadeEffectOptions { crossFade boolean false transformEl CSSSelector null } Coverflow Effect Parameters
NameTypeDefaultDescription coverflowEffect CoverflowEffectOptions { depth number 100 modifier number 1 rotate number 50 scale number 1 slideShadows boolean true stretch number 0 transformEl CSSSelector null } Flip Effect Parameters
NameTypeDefaultDescription flipEffect FlipEffectOptions { limitRotation boolean true slideShadows boolean true transformEl CSSSelector null } Cube Effect Parameters
NameTypeDefaultDescription cubeEffect CubeEffectOptions { shadow boolean true shadowOffset number 20 shadowScale number 0.94 slideShadows boolean true } Cards Effect Parameters
NameTypeDefaultDescription cardsEffect CardsEffectOptions { slideShadows boolean true transformEl CSSSelector null } Creative Effect Parameters
NameTypeDefaultDescription creativeEffect CreativeEffectOptions { limitProgress number 1 next CreativeEffectTransform perspective boolean true prev CreativeEffectTransform progressMultiplier number 1 shadowPerProgress boolean false transformEl CSSSelector null } Thumbs Parameters
NameTypeDefaultDescription thumbs ThumbsOptions { autoScrollOffset number 0 multipleActiveThumbs boolean true slideThumbActiveClass string 'swiper-slide-thumb-active' swiper null | Swiper null thumbsContainerClass string 'swiper-thumbs' } Thumbs Methods
Zoom Parameters
NameTypeDefaultDescription zoom boolean | ZoomOptions { containerClass string 'swiper-zoom-container' maxRatio number 3 minRatio number 1 toggle boolean true zoomedSlideClass string 'swiper-slide-zoomed' } Zoom Methods
Zoom Events
NameArgumentsDescription zoomChange [swiper, scale, imageEl, slideEl] NameTypeDefaultDescription keyboard boolean | KeyboardOptions { enabled boolean false onlyInViewport boolean true pageUpDown boolean true } NameArgumentsDescription keyPress [swiper, keyCode] NameTypeDefaultDescription mousewheel boolean | MousewheelOptions { eventsTarget 'container' | CSSSelector | HTMLElement | 'wrapper' 'container' forceToAxis boolean false invert boolean false releaseOnEdges boolean false sensitivity number 1 thresholdDelta null | number null thresholdTime null | number null } NameArgumentsDescription scroll [swiper, event] NameTypeDefaultDescription virtual boolean | VirtualOptions { addSlidesAfter number 0 addSlidesBefore number 0 cache boolean true enabled boolean renderExternal function[data] renderExternalUpdate boolean true renderSlide function[slide, index] slides any[] [] } NameTypeDefaultDescription hashNavigation boolean | HashNavigationOptions { replaceState boolean false watchState boolean false } NameArgumentsDescription hashChange [swiper] hashSet [swiper] NameTypeDefaultDescription history boolean | HistoryOptions { key string 'slides' replaceState boolean false root string '' } NameTypeDefaultDescription controller ControllerOptions { by 'slide' | 'container' 'slide' control Swiper | Swiper[] inverse boolean false } Properties swiper.controller.control Swiper | Swiper[] NameTypeDefaultDescription a11y A11yOptions { containerMessage null | string null containerRoleDescriptionMessage null | string null enabled boolean true firstSlideMessage string 'This is the first slide' itemRoleDescriptionMessage null | string null lastSlideMessage string 'This is the last slide' nextSlideMessage string 'Next slide' notificationClass string 'swiper-notification' paginationBulletMessage string 'Go to slide {{index}}' prevSlideMessage string 'Previous slide' slideLabelMessage string '{{index}} / {{slidesLength}}' slideRole string 'group' } Using JS Modules
Using Build Script
Video liên quan