Skip to content

Commit

Permalink
fix(navigation): allow multiple classes in navigation options (#6345)
Browse files Browse the repository at this point in the history
Allow multiple classes in `disabledClass`, `navigationDisabledClass` and `lockClass`.

fixes #6344
  • Loading branch information
benedictdudel authored Feb 6, 2023
1 parent 3608b75 commit ca49b9f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/modules/navigation/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function Navigation({ swiper, extendParams, on, emit }) {
el = makeElementsArray(el);
el.forEach((subEl) => {
if (subEl) {
subEl.classList[disabled ? 'add' : 'remove'](params.disabledClass);
subEl.classList[disabled ? 'add' : 'remove'](...params.disabledClass.split(' '));
if (subEl.tagName === 'BUTTON') subEl.disabled = disabled;
if (swiper.params.watchOverflow && swiper.enabled) {
subEl.classList[swiper.isLocked ? 'add' : 'remove'](params.lockClass);
Expand Down Expand Up @@ -112,7 +112,7 @@ export default function Navigation({ swiper, extendParams, on, emit }) {
el.addEventListener('click', dir === 'next' ? onNextClick : onPrevClick);
}
if (!swiper.enabled && el) {
el.classList.add(params.lockClass);
el.classList.add(...params.lockClass.split(' '));
}
};

Expand All @@ -125,7 +125,7 @@ export default function Navigation({ swiper, extendParams, on, emit }) {
prevEl = makeElementsArray(prevEl);
const destroyButton = (el, dir) => {
el.removeEventListener('click', dir === 'next' ? onNextClick : onPrevClick);
el.classList.remove(swiper.params.navigation.disabledClass);
el.classList.remove(...swiper.params.navigation.disabledClass.split(' '));
};
nextEl.forEach((el) => destroyButton(el, 'next'));
prevEl.forEach((el) => destroyButton(el, 'prev'));
Expand Down Expand Up @@ -191,13 +191,13 @@ export default function Navigation({ swiper, extendParams, on, emit }) {
});

const enable = () => {
swiper.el.classList.remove(swiper.params.navigation.navigationDisabledClass);
swiper.el.classList.remove(...swiper.params.navigation.navigationDisabledClass.split(' '));
init();
update();
};

const disable = () => {
swiper.el.classList.add(swiper.params.navigation.navigationDisabledClass);
swiper.el.classList.add(...swiper.params.navigation.navigationDisabledClass.split(' '));
destroy();
};

Expand Down

0 comments on commit ca49b9f

Please sign in to comment.