/* ================================================================================== * Template: Namu - Personal Portfolio HTML Template * Written by: Harnish Design - (http://www.harnishdesign.net) * Description: Main Custom Script File ================================================================================== */ (function ($) { "use strict"; // Preloader $(window).on('load', function () { $('.lds-ellipsis').fadeOut(); // will first fade out the loading animation $('.preloader').delay(333).fadeOut('slow'); // will fade out the white DIV that covers the website. $('body').delay(333); }); // Header Sticky $(window).on('scroll',function() { var stickytop = $('#header.sticky-top .bg-transparent'); var stickytopslide = $('#header.sticky-top-slide'); if ($(this).scrollTop() > 1){ stickytop.addClass("sticky-on-top"); stickytop.find(".logo img").attr('src',stickytop.find('.logo img').data('sticky-logo')); } else { stickytop.removeClass("sticky-on-top"); stickytop.find(".logo img").attr('src',stickytop.find('.logo img').data('default-logo')); } if ($(this).scrollTop() > 180){ stickytopslide.find(".primary-menu").addClass("sticky-on"); stickytopslide.find(".logo img").attr('src',stickytopslide.find('.logo img').data('sticky-logo')); } else{ stickytopslide.find(".primary-menu").removeClass("sticky-on"); stickytopslide.find(".logo img").attr('src',stickytopslide.find('.logo img').data('default-logo')); } }); // Sections Scroll $('.smooth-scroll').on('click', function() { event.preventDefault(); var sectionTo = $(this).attr('href'); $('html, body').stop().animate({ scrollTop: $(sectionTo).offset().top - 50}, 1500, 'easeInOutExpo'); }); /*--------------------------------------------------- Primary Menu ----------------------------------------------------- */ // Dropdown show on hover $('.primary-menu:not(.navbar-overlay):not(.navbar-expand-none) ul.navbar-nav li.dropdown').on("mouseover", function() { if ($(window).width() > 991) { $(this).find('> .dropdown-menu').stop().slideDown('fast'); $(this).on('mouseleave', function() { $(this).find('> .dropdown-menu').stop().css('display', 'none'); }); // When dropdown going off to the out of the screen. $('.primary-menu ul.navbar-nav > li.dropdown > .dropdown-menu').each(function() { var menu = $('#header .primary-menu > div').offset(); var dropdown = $(this).parent().offset(); if ($("html").attr("dir") == 'rtl') { var rd = ($(window).width() - (dropdown.left + $(this).parent().outerWidth())); var i = (rd + $(this).outerWidth()) - (menu.left + $('#header .primary-menu > div').outerWidth()); }else{ var i = (dropdown.left + $(this).outerWidth()) - (menu.left + $('#header .primary-menu > div').outerWidth()); } if (i > 0) { if ($("html").attr("dir") == 'rtl') { $(this).css('margin-right', '-' + (i) + 'px'); }else{ $(this).css('margin-left', '-' + (i) + 'px'); } } }); } }); $(function () { $(".dropdown li").on('mouseenter mouseleave', function (e) { if ($(window).width() > 991) { if ($('.dropdown-menu', this).length) { var elm = $('.dropdown-menu', this); var off = elm.offset(); var l = off.left; var w = elm.width(); var docW = $(window).width(); var lr = ($(window).width() - (off.left + elm.outerWidth())); //offset right if ($("html").attr("dir") == 'rtl') { var isEntirelyVisible = (lr + w + 30 <= docW); }else{ var isEntirelyVisible = (l + w + 30 <= docW); } if (!isEntirelyVisible) { $(elm).addClass('dropdown-menu-end'); $(elm).parents('.dropdown:first').find('> a.dropdown-toggle > .arrow').addClass('arrow-end'); } else { $(elm).removeClass('dropdown-menu-end'); $(elm).parents('.dropdown:first').find('> a.dropdown-toggle > .arrow').removeClass('arrow-end'); } } } }); }); // DropDown Arrow $('.primary-menu').find('a.dropdown-toggle').append($('').addClass('arrow')); // Mobile Collapse Nav $('.primary-menu .dropdown-toggle[href="#"], .primary-menu .dropdown-toggle[href!="#"] .arrow').on('click', function(e) { if ($('nav').hasClass('navbar-overlay') && $('nav').hasClass('navbar-expand-none')) { var ww = 4000; }else{ var ww = 991; } if ($(window).width() < (ww)) { e.preventDefault(); var $parentli = $(this).closest('li'); $parentli.siblings('li').find('.dropdown-menu:visible').slideUp(); $parentli.find('> .dropdown-menu').stop().slideToggle(); $parentli.siblings('li').find('a .arrow.show').toggleClass('show'); $parentli.find('> a .arrow').toggleClass('show'); } }); // Mobile Menu $('.navbar-toggler').on('click', function() { $(this).toggleClass('show'); $('#header.sticky-top-slide').find(".primary-menu").toggleClass("show"); }); $('.navbar-nav a:not(.dropdown-toggle)').on('click', function() { $('.navbar-collapse, .navbar-toggler').removeClass('show'); }); // Overlay Menu $('.navbar-overlay .collapse').on('show.bs.collapse hide.bs.collapse', function(e) { e.preventDefault(); }), $('.navbar-overlay [data-bs-toggle="collapse"]').on('click', function(e) { e.preventDefault(); $($(this).data('bs-target')).toggleClass('show'); }) /*--------------------------------- Carousel (Owl Carousel) ----------------------------------- */ $(".owl-carousel").each(function (index) { var a = $(this); $(this).owlCarousel({ rtl: a.data('rtl'), autoplay: a.data('autoplay'), autoplayTimeout: a.data('autoplaytimeout'), smartSpeed: a.data('smartspeed'), slideTransition: a.data('slidetransition'), autoplayHoverPause: a.data('autoplayhoverpause'), loop: a.data('loop'), speed: a.data('speed'), nav: a.data('nav'), dots: a.data('dots'), center: a.data('center'), autoHeight: a.data('autoheight'), autoWidth: a.data('autowidth'), margin: a.data('margin'), stagePadding: a.data('stagepadding'), slideBy: a.data('slideby'), lazyLoad: a.data('lazyload'), //navText:['', ''], animateOut: a.data('animateout'), animateIn: a.data('animatein'), video: a.data('video'), items: a.data('items'), responsive:{ 0:{items: a.data('items-xs'),}, 576:{items: a.data('items-sm'),}, 768:{items: a.data('items-md'),}, 992:{items: a.data('items-lg'),} } }); }); /*------------------------------------ Magnific Popup -------------------------------------- */ // Image on Modal $('.popup-img').each(function() { $(this).magnificPopup({ //delegate: '.popup-img:visible', type: "image", tLoading: '