There is an OwlCarousel with photos, when clicked, double-clicking should open the fancybox gallery.
The fact is that the gallery opens by default by a single click.
And sometimes even just when you try to make a roundabout swipe, a modal window opens, but this should not be.
I want to prohibit opening a single-click fan box and listening to a double one.
I can cancel the first click, double occurs, but the fanbox is not detected ..:
function init() { initFancybox(); initGallerySlider(); } window.onload = init; function initGallerySlider() { $('.gallery').owlCarousel({ loop: true, margin: 0, autoWidth: true }); } function initFancybox() { $(document).on('fancybox.init', '.fancybox', function() { var defaults = { maxWidth: 994, autoResize: true, padding: 0, helpers: { media: {}, overlay: {} } }, $el = $(this), group = $el.attr('data-fancybox-group'), options = eval('[' + $el.data('fancybox-options') + ']')[0]; if (group) $el = $('[data-fancybox-group="' + group + '"]'); $.extend(defaults, options); $el.fancybox(defaults); }); $('.fancybox').trigger('fancybox.init'); } $('[data-fancybox="gallery"]').click(function(e) { e.preventDefault(); }); $('[data-fancybox="gallery"]').dblclick(function() { $(this).fancybox(); }); .gallery__item { display: block; height: 200px; width: 200px; background-size: cover; } <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.2.1/assets/owl.carousel.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.2.5/jquery.fancybox.min.css" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.2.1/owl.carousel.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.2.5/jquery.fancybox.min.js"></script> <div class="container"> <div class="row"> <div class="col-12"> <div class="gallery owl-carousel"> <a href="https://i0.wallpaperscraft.com/image/usa_california_san_francisco_night_panorama_69288_300x300.jpg" class="gallery__item" data-fancybox="gallery" style="background-image: url(https://i0.wallpaperscraft.com/image/usa_california_san_francisco_night_panorama_69288_300x300.jpg);"></a> <a href="http://i0.wallpaperscraft.ru/image/sirs-tauer_neboskrb_chikago_ssha_hdr_47960_300x300.jpg" class="gallery__item" data-fancybox="gallery" style="background-image: url(http://i0.wallpaperscraft.ru/image/sirs-tauer_neboskrb_chikago_ssha_hdr_47960_300x300.jpg);"></a> <a href="http://i0.wallpaperscraft.ru/image/ulica_karla_libknehta_panorama_ekaterinburg_rossiya_28661_300x300.jpg" class="gallery__item" data-fancybox="gallery" style="background-image: url(http://i0.wallpaperscraft.ru/image/ulica_karla_libknehta_panorama_ekaterinburg_rossiya_28661_300x300.jpg);"></a> <a href="https://weatherbyhealthcare.scdn5.secure.raxcdn.com/blog/wp-content/uploads/2015/03/pennsylvania_destination_300.jpg" class="gallery__item" data-fancybox="gallery" style="background-image: url(https://weatherbyhealthcare.scdn5.secure.raxcdn.com/blog/wp-content/uploads/2015/03/pennsylvania_destination_300.jpg);"></a> <a href="http://2015.ctbuh.org/wp-content/uploads/2015/05/Chicago_sunrise_cDanielSchwen-300x300.jpg" class="gallery__item" data-fancybox="gallery" style="background-image: url(http://2015.ctbuh.org/wp-content/uploads/2015/05/Chicago_sunrise_cDanielSchwen-300x300.jpg);"></a> </div> <!--.gallery.owl-carousel--> </div> <!--col--> </div> <!--.row--> </div> <!--.container-->
*.fancybox is not a function- kizosofancyboxclass? - Grundy