up
This commit is contained in:
@@ -216,24 +216,57 @@
|
||||
|
||||
|
||||
// HERO SLIDER
|
||||
if (typeof Swiper === "function" && jQuery(".hero-slider .swiper-container").length) {
|
||||
var heroSwiper = null;
|
||||
var heroSlideCount = 0;
|
||||
var heroAutoplayOptions = {
|
||||
delay: 6500,
|
||||
disableOnInteraction: false,
|
||||
stopOnLastSlide: false
|
||||
};
|
||||
|
||||
function applyHeroInterleave(swiper) {
|
||||
if (!swiper || !swiper.slides) {
|
||||
return;
|
||||
}
|
||||
|
||||
var interleaveOffset = getHeroInterleaveOffset();
|
||||
var innerOffset = (swiper.width || 0) * interleaveOffset;
|
||||
|
||||
for (var i = 0; i < swiper.slides.length; i++) {
|
||||
var slideProgress = Math.max(Math.min(swiper.slides[i].progress || 0, 1), -1);
|
||||
var innerTranslate = slideProgress * innerOffset;
|
||||
var slideInner = swiper.slides[i].querySelector(".slide-inner");
|
||||
|
||||
if (slideInner) {
|
||||
slideInner.style.transform =
|
||||
"translate3d(" + innerTranslate + "px, 0, 0)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function initHeroSlider() {
|
||||
if (heroSwiper) {
|
||||
return heroSwiper;
|
||||
}
|
||||
|
||||
if (typeof Swiper !== "function" || !jQuery(".hero-slider .swiper-container").length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var $heroSlider = jQuery(".hero-slider .swiper-container");
|
||||
var menu = [];
|
||||
$heroSlider.find('.swiper-slide').each( function(index){
|
||||
menu.push( jQuery(this).find('.slide-inner').attr("data-text") );
|
||||
});
|
||||
var totalSlides = $heroSlider.find(".swiper-slide").length;
|
||||
var shouldLoop = totalSlides > 2;
|
||||
var shouldLoop = totalSlides > 1;
|
||||
|
||||
heroSlideCount = totalSlides;
|
||||
|
||||
var swiperOptions = {
|
||||
loop: shouldLoop,
|
||||
initialSlide: 0,
|
||||
preloadImages: true,
|
||||
updateOnImagesReady: true,
|
||||
speed: 1000,
|
||||
parallax: true,
|
||||
autoplay: totalSlides > 1 ? {
|
||||
delay: 6500,
|
||||
disableOnInteraction: false,
|
||||
} : false,
|
||||
autoplay: false,
|
||||
watchSlidesProgress: true,
|
||||
pagination: {
|
||||
el: '.swiper-pagination',
|
||||
@@ -246,20 +279,12 @@
|
||||
},
|
||||
|
||||
on: {
|
||||
progress: function() {
|
||||
var swiper = this;
|
||||
var interleaveOffset = getHeroInterleaveOffset();
|
||||
for (var i = 0; i < swiper.slides.length; i++) {
|
||||
var slideProgress = Math.max(Math.min(swiper.slides[i].progress, 1), -1);
|
||||
var innerOffset = swiper.width * interleaveOffset;
|
||||
var innerTranslate = slideProgress * innerOffset;
|
||||
var slideInner = swiper.slides[i].querySelector(".slide-inner");
|
||||
init: function() {
|
||||
applyHeroInterleave(this);
|
||||
},
|
||||
|
||||
if (slideInner) {
|
||||
slideInner.style.transform =
|
||||
"translate3d(" + innerTranslate + "px, 0, 0)";
|
||||
}
|
||||
}
|
||||
progress: function() {
|
||||
applyHeroInterleave(this);
|
||||
},
|
||||
|
||||
touchStart: function() {
|
||||
@@ -287,15 +312,51 @@
|
||||
swiperOptions.loopedSlides = totalSlides;
|
||||
}
|
||||
|
||||
var swiper = new Swiper(".hero-slider .swiper-container", swiperOptions);
|
||||
heroSwiper = new Swiper(".hero-slider .swiper-container", swiperOptions);
|
||||
applyHeroInterleave(heroSwiper);
|
||||
|
||||
return heroSwiper;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------
|
||||
= HIDE PRELOADER
|
||||
-------------------------------------------*/
|
||||
function hidePreloader() {
|
||||
|
||||
function resetHeroToFirstSlide() {
|
||||
if (!heroSwiper) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (heroSwiper.params && heroSwiper.params.loop && typeof heroSwiper.slideToLoop === "function") {
|
||||
heroSwiper.slideToLoop(0, 0, false);
|
||||
} else if (typeof heroSwiper.slideTo === "function") {
|
||||
heroSwiper.slideTo(0, 0, false);
|
||||
}
|
||||
|
||||
if (typeof heroSwiper.updateProgress === "function") {
|
||||
heroSwiper.updateProgress();
|
||||
}
|
||||
|
||||
if (typeof heroSwiper.updateSlidesClasses === "function") {
|
||||
heroSwiper.updateSlidesClasses();
|
||||
}
|
||||
|
||||
applyHeroInterleave(heroSwiper);
|
||||
}
|
||||
|
||||
function startHeroAutoplay() {
|
||||
resetHeroToFirstSlide();
|
||||
|
||||
if (!heroSwiper || heroSlideCount <= 1 || !heroSwiper.autoplay || typeof heroSwiper.autoplay.start !== "function") {
|
||||
return;
|
||||
}
|
||||
|
||||
heroSwiper.params.autoplay = $.extend({}, heroAutoplayOptions);
|
||||
heroSwiper.autoplay.start();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------
|
||||
= HIDE PRELOADER
|
||||
-------------------------------------------*/
|
||||
function hidePreloader(onHidden) {
|
||||
$('.preloader').delay(100).fadeOut(500, function() {
|
||||
|
||||
//active wow
|
||||
@@ -303,14 +364,27 @@
|
||||
wow.init();
|
||||
}
|
||||
|
||||
if (typeof onHidden === "function") {
|
||||
onHidden();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function preloader() {
|
||||
if($('.preloader').length) {
|
||||
waitForHeroBackgrounds(hidePreloader);
|
||||
waitForHeroBackgrounds(function() {
|
||||
initHeroSlider();
|
||||
resetHeroToFirstSlide();
|
||||
hidePreloader(startHeroAutoplay);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
initHeroSlider();
|
||||
resetHeroToFirstSlide();
|
||||
startHeroAutoplay();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user