(function ($) {$(function(){ // Ленивая загрузка observer = lozad('.lozad:not(loaded)', { rootMargin: '400px 400px', threshold: 0, loaded: function(el) { el.classList.add('loaded') } }) observer.observe() // Проверка браузера if ( !supportsCssVars() ) { $('body').addClass('lock') $('.supports_error').addClass('show') } // Установка ширины стандартного скроллбара $(':root').css('--scroll_width', widthScroll() + 'px') }) $(window).on("load", function (e) { if ( $(window).width() > 1024 ) { inView.offset(150) if( $('.advantage').length ) { inView('.advantage') .on('enter', function(el){ setTimeout(function(){ $(el).find('.advantage__slide:eq(0) .advantage__box').addClass('animate__animated animate__fadeIn') }, 200) setTimeout(function(){ $(el).find('.advantage__slide:eq(1) .advantage__box').addClass('animate__animated animate__fadeIn') }, 600) setTimeout(function(){ $(el).find('.advantage__slide:eq(2) .advantage__box').addClass('animate__animated animate__fadeIn') }, 1000) }) } } // Бегущая строка $('.countries').liMarquee({ drag: false, hoverstop: false }) // Слайдер преимуществ $('.advantage').owlCarousel({ loop: false, smartSpeed: 500, nav: true, dots: false, mouseDrag: false, responsive: { 0:{ items: 1, margin: 20 }, 480:{ items: 2, margin: 20 }, 768:{ items: 2, margin: 26 }, 1025:{ items: 3, margin: 30 } }, onInitialized: function(event){ $(event.target).find('.advantage__slide').height('auto') setHeight( $(event.target).find('.advantage__slide') ) }, onResized: function(event){ $(event.target).find('.advantage__slide').height('auto') setHeight( $(event.target).find('.advantage__slide') ) } }) }) // Вспомогательные функции var supportsCssVars = function() { var s = document.createElement('style'), support s.innerHTML = ":root { --tmp-var: bold; }" document.head.appendChild(s) support = !!(window.CSS && window.CSS.supports && window.CSS.supports('font-weight', 'var(--tmp-var)')) s.parentNode.removeChild(s) return support } function widthScroll() { var div = document.createElement('div') div.style.overflowY = 'scroll' div.style.width = '50px' div.style.height = '50px' div.style.visibility = 'hidden' document.body.appendChild(div) var scrollWidth = div.offsetWidth - div.clientWidth document.body.removeChild(div) return scrollWidth } function setHeight(className){ var maxheight = 0 var object = $(className) object.each(function() { var elHeight = $(this).innerHeight() if( elHeight > maxheight ) { maxheight = elHeight } }) object.innerHeight( maxheight ) };})(jQuery);