南宫28

$(document).ready(function() { var bLazy = new Blazy({ breakpoints: [ { width: 767, src: 'data-src-mobiles' }, { width: 1200, src: 'data-src-webp' } ] }); // animation var anim = $('.animation'); if (anim != null){ if (animatonViewport(anim[0])) { anim[0].classList.add("in-viewport"); } window.addEventListener('scroll', function (event) { for (var i = 0; i < anim.length; i++) { if (animatonViewport(anim[i])) { anim[i].classList.add("in-viewport"); } } }, false); } // Video Control var vidBtn = $('.video_control_btn'); var heroVdieo = document.querySelector('video'); vidBtn.on('click', function(event){ var $this = $(this); if ($this.hasClass("pause")) { $this.removeClass("pause").addClass("resume"); heroVdieo.pause(); } else if ($this.hasClass("resume")) { $this.removeClass("resume").addClass("pause"); heroVdieo.play(); } }); var videoTrigger = $(".trigger")[0]; var videoLoaded = false; var mediaQuote = $(".media-detect-point-enter")[0]; var mediaQuoteLoaded = false; window.addEventListener('scroll', function (event) { if (videoTrigger != null){ //if (triggerInViewport(videoTrigger) && videoLoaded != true) { if (triggerInViewport(videoTrigger)) { if (document.querySelector('source')) { vidBtn.removeClass("resume").addClass("pause"); heroVdieo.play(); } else { heroVdieo.setAttribute('poster', 'assets/images/img/home/wdVideos_1_video.webp') var source = document.createElement('source'); source.src = 'assets/images/img/home/wdVideos_1_video.mp4'; source.type = 'video/mp4'; heroVdieo.appendChild(source); //videoLoaded = true; } } else { vidBtn.removeClass("pause").addClass("resume"); heroVdieo.pause(); } } if (isInViewport(mediaQuote)) { if (mediaQuoteLoaded == true) { return; } else { console.log("load carousel"); $(".owl-carousel").owlCarousel({ //center: true, items:1, slideBy: 1, mouseDrag: false, loop:true, //margin:0, //nav:true, dot:true, // slideTransition: "linear", fluidSpeed: true, smartSpeed: 800, autoHeight:true, autoplay:false, autoplayTimeout:5000, autoplayHoverPause:true, //onChanged: teamsCallback onInitialized : function() { //console.log("init"); //add dots accessible names $('.owl-carousel .owl-dot').each(function(index) { //Add one to index so it starts from 1 $(this).attr('aria-label', 'banner ' + (index + 1)).attr('tabindex','0'); }); $('.owl-carousel .owl-item').attr('aria-selected','false'); $('.owl-carousel .owl-item.active').attr('aria-selected','true'); // let screen readers know an item is active // apply meta info to next and previous buttons and make them focusable $('.owl-carousel .owl-prev').attr('role','button').attr('title','Previous'); $('.owl-carousel .owl-next').attr('role','button').attr('title','Next'); $('.owl-carousel, .owl-prev, .owl-next').attr('tabindex','0'); // add instructions to keyboard users that are only visible when the carousel is focused $('.owl-carousel .owl-wrapper-outer').append(''); // listen for keyboard input $(document).on('keydown', function(e){ var $focusedElement = $(document.activeElement), singleOwl = $(".owl-carousel").data('owlCarousel'), type = e.which == 39? 'next': null, type = e.which == 37? 'prev': type, type = e.which == 13? 'enter':type; // if the carousel is focused, use left and right arrow keys to navigate if($focusedElement.attr('id') === 'media-quote'){ if (type == 'next') { singleOwl.next(); } else if (type == 'prev') { singleOwl.prev(); } // if the prev and next buttons are focused, catch "Enter" and navigate in the right direction } else if (type == 'enter') { if ($focusedElement.hasClass('owl-next')) { singleOwl.next(); } else if ($focusedElement.hasClass('owl-prev')) { singleOwl.prev(); } } }); }, // let screen readers know which slide is active after navigation or reinit onTranslated : function() { $('.owl-carousel .owl-item').attr('aria-selected','false'); $('.owl-carousel .owl-item.active').attr('aria-selected','true'); } }); mediaQuoteLoaded = true; } } }, false); });