Skip to content

Commit

Permalink
feat(core): make slidesPerViewDynamic public
Browse files Browse the repository at this point in the history
fixes #7036
  • Loading branch information
nolimits4web committed Sep 19, 2023
1 parent 8b73864 commit ae434b0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core/core.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ class Swiper {
const swiper = this;
const { params, slides, slidesGrid, slidesSizesGrid, size: swiperSize, activeIndex } = swiper;
let spv = 1;
if (typeof params.slidesPerView === 'number') return params.slidesPerView;

if (params.centeredSlides) {
let slideSize = slides[activeIndex] ? slides[activeIndex].swiperSlideSize : 0;
Expand Down
6 changes: 6 additions & 0 deletions src/types/swiper-class.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ interface Swiper extends SwiperClass<SwiperEvents> {
*/
slideToClosest(speed?: number, runCallbacks?: boolean): void;

/**
* Get dynamically calculated amount of slides per view, useful only when slidesPerView set to `auto`
*
*/
slidesPerViewDynamic(): number;

/**
* Force swiper to update its height (when autoHeight enabled) for the duration equal to
* 'speed' parameter
Expand Down

0 comments on commit ae434b0

Please sign in to comment.