// intialization plugins
$(document).ready(function () {

    //animation icon toggler of navbar
    $(`.navbar-toggler`).click(function() {
        $(`.navbar-toggler`).toggleClass(`active`);
    });

    // navbar-fixed-top
    $(function () {
        $(document).scroll(function () {
            var $nav = $(".navbar-fixed-top");
            $nav.toggleClass('scrolled', $(this).scrollTop() > $nav.height());
        });
    });

    //Wow intit
    wow = new WOW({
        boxClass: 'wow',
        animateClass: 'animated',
        offset: 200,
        mobile: true,
        live: false
    });
    wow.init();

    //fancybox
    $("[data-fancybox]").fancybox({
        selector: '[data-fancybox="images"]',
        // loop: true
    });

    //  loader 
    // $(window).on("load", function() {
    //     $("#preloader").addClass("isdone");
    // });

});


$(document).ready(function() {
    setTimeout(function() {
       $('body').addClass('loaded');
   }, 100);

});

// Swiper
$(document).ready(function () {

    //////////////////// Swiper  ////////////////////
    var swiper = new Swiper('.partners_sec .partner_swiper', {
        loop: true,
        speed: 3000,
        slidesPerView: 2,
        spaceBetween: 15,
        freeMode: true,
        loopAddBlankSlides:true,
        // cssMode:true,
        grabCursor: true,
        loopAdditionalSlides: 2,
        autoplay: {
            delay: 0,
            disableOnInteraction:false,
        },
        navigation: {
            nextEl: '.sponsors_sec2 .swiper-button-next',
            prevEl: '.sponsors_sec2 .swiper-button-prev',
        },
        pagination: {
            el: '.swiper-pagination',
            clickable: true
        },
        breakpoints: {
            640: {
                slidesPerView: 2,
                spaceBetween: 20,
            },
            768: {
                slidesPerView: 3,
                spaceBetween: 20,
            },
            1024: {
                slidesPerView: 5,
                spaceBetween: 20,
            },
        }
    });

    //////////////////// Swiper  ////////////////////
    var swiper = new Swiper('.feedback_sec .feedback_swiper', {
        // loop: true,
        speed: 900,
        slidesPerView: 1,
        spaceBetween: 15,
        // autoplay: {
        //     delay: 2500,
        // },
        navigation: {
            nextEl: '.feedback_sec .swiper-button-next',
            prevEl: '.feedback_sec .feedback_sec .swiper-button-prev',
        },
        pagination: {
            el: '.feedback_sec .swiper-pagination',
            clickable: true
        },
        breakpoints: {
            640: {
                slidesPerView: 2,
                spaceBetween: 20,
            },
            1024: {
                slidesPerView: 3,
                spaceBetween: 20,
            },
        }
    });

    //////////////////// Swiper  ////////////////////
    // var swiper = new Swiper(' .swiper-container', {
    //     // loop: true,
    //     speed: 900,
    //     slidesPerView: 1,
    //     spaceBetween: 15,
    //     // autoplay: {
    //     //     delay: 2500,
    //     // },
    //     //In Tabs
    //     // observer: true,
    //     // observeParents: true,
    //     navigation: {
    //         nextEl: '.swiper-button-next',
    //         prevEl: '.swiper-button-prev',
    //     },
    //     pagination: {
    //         el: '.swiper-pagination',
    //         clickable: true
    //     },
    //     breakpoints: {
    //         640: {
    //             slidesPerView: 2,
    //             spaceBetween: 20,
    //         },
    //         768: {
    //             slidesPerView: 3,
    //             spaceBetween: 20,
    //         },
    //         1024: {
    //             slidesPerView: 5,
    //             spaceBetween: 20,
    //             // Prevent swiper in lg screens
    //             // allowTouchMove: false,
    //             // preventClicks: false
    //         },
    //     }
    // });

});

$(function() {  
    $('.butn')
      .on('mouseenter', function(e) {
              var parentOffset = $(this).offset(),
                relX = e.pageX - parentOffset.left,
                relY = e.pageY - parentOffset.top;
              $(this).find('.circle').css({top:relY, left:relX})
      })
      .on('mouseout', function(e) {
              var parentOffset = $(this).offset(),
                relX = e.pageX - parentOffset.left,
                relY = e.pageY - parentOffset.top;
          $(this).find('.circle').css({top:relY, left:relX})
      });
  });


// ------------ gsap scripts -----------
$(function () {

    gsap.registerPlugin(ScrollTrigger, ScrollSmoother);

    const smoother = ScrollSmoother.create({
        content: "#scrollsmoother-container",
        smooth: 1.5,
        normalizeScroll: true,
        ignoreMobileResize: true,
        effects: true,
    });

    gsap.timeline({ scrollTrigger: { 
        trigger: ".about_sec",  start: "-600 top",  scrub: !0 
    } }).to(".about_sec .imgSec", {
            x: 0, y: 0, scale: 1.3, duration: 20, ease: "linear", delay: 1 
        }
    ),
    gsap.timeline({ scrollTrigger: { 
        trigger: ".features_sec",  start: "-600 top",  scrub: !0 
    } }).to(".features_sec .secImg", {
            x: -50, y: 0, scale: 1, duration: 20, ease: "linear", delay: 0 
        }
    ),
    gsap.timeline({ scrollTrigger: { 
        trigger: ".uses_sec",  start: "-600 top",  scrub: !0 
    } }).to(".uses_sec .imgSec", {
            x: 0, y: 0, scale: 1.3, duration: 20, ease: "linear", delay: 1 
        }
    ),
    gsap.timeline({ scrollTrigger: { 
        trigger: ".join_sec",  start: "-600 top",  scrub: !0 
    } }).to(".join_sec .secImg", {
            x: 50, y: 0, scale: 1, duration: 20, ease: "linear", delay: 0 
        }
    ),
    gsap.timeline({ scrollTrigger: { 
        trigger: ".header",  start: "-600 top",  scrub: !0 
    } }).to(".header .header_img", {
        x: -100,
        y: 10,
        scale: 1,
        duration: 20,
        ease: "none",
        delay: 0,
        // rotationZ: -90,
        }
    );



});

