Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/core/breakpoints/setBreakpoint.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getDocument } from 'ssr-window';
import { extend } from '../../shared/utils.mjs';

const isGridEnabled = (swiper, params) => {
Expand All @@ -9,9 +10,19 @@ export default function setBreakpoint() {
const { realIndex, initialized, params, el } = swiper;
const breakpoints = params.breakpoints;
if (!breakpoints || (breakpoints && Object.keys(breakpoints).length === 0)) return;

// Get breakpoint for window width and update parameters
const breakpoint = swiper.getBreakpoint(breakpoints, swiper.params.breakpointsBase, swiper.el);
const document = getDocument();

// Get breakpoint for window/container width and update parameters
const breakpointsBase =
params.breakpointsBase === 'window' || !params.breakpointsBase
? params.breakpointsBase
: 'container';
const breakpointContainer =
['window', 'container'].includes(params.breakpointsBase) || !params.breakpointsBase
? swiper.el
: document.querySelector(params.breakpointsBase);

const breakpoint = swiper.getBreakpoint(breakpoints, breakpointsBase, breakpointContainer);

if (!breakpoint || swiper.currentBreakpoint === breakpoint) return;

Expand Down
2 changes: 1 addition & 1 deletion src/types/swiper-options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ export interface SwiperOptions {
*
* @default 'window'
*/
breakpointsBase?: 'window' | 'container';
breakpointsBase?: 'window' | 'container' | CSSSelector;

// Observer
/**
Expand Down