7

Fancybox breaks swiper. Adds offset without visible CSS and DOM changes. To replicate the issue on jsbin (https://output.jsbin.com/jiqucacete) you need:

new Swiper('.swiper-container', {
  slidesPerView: 1
});

1) Press on the swiper slide image 2) Go to next image in fancybox gallery popup 3) Close gallery and there will be slide change in swiper

How does it work? Why there aren't visible any CSS, DOM changes? How to fix?

1 Answer 1

12

fancybox places focus back on the trigger element after closing the gallery and sometimes carousel/slider scripts are sensitive to this feature. To disable that, set backFocus:false, for example:

$.fancybox.defaults.backFocus = false;
2
  • This answer saved my day :)
    – user5542604
    Commented Jun 23, 2020 at 14:34
  • This save my night!!! Thanks a lot!
    – ferrari
    Commented Jun 24, 2022 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.