Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(navigation): allow multiple classes in navigation options #6345

Merged
Merged
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
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