You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

script.js 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /* ========================================================================= */
  2. /* Page Preloader
  3. /* ========================================================================= */
  4. $(window).on('load', function () {
  5. $('.preloader').fadeOut(100);
  6. });
  7. jQuery(function ($) {
  8. "use strict";
  9. /* ========================================================================= */
  10. /* Auto close Navbar when click on link
  11. /* ========================================================================= */
  12. $('.navbar-collapse a').click(function () {
  13. $(".navbar-collapse").collapse('hide');
  14. });
  15. /* ========================================================================= */
  16. /* lazy load initialize
  17. /* ========================================================================= */
  18. const observer = lozad(); // lazy loads elements with default selector as ".lozad"
  19. observer.observe();
  20. /* ========================================================================= */
  21. /* Magnific popup
  22. /* ========================================================================= */
  23. $('.image-popup').magnificPopup({
  24. type: 'image',
  25. removalDelay: 160, //delay removal by X to allow out-animation
  26. callbacks: {
  27. beforeOpen: function () {
  28. // just a hack that adds mfp-anim class to markup
  29. this.st.image.markup = this.st.image.markup.replace('mfp-figure', 'mfp-figure mfp-with-anim');
  30. this.st.mainClass = this.st.el.attr('data-effect');
  31. }
  32. },
  33. closeOnContentClick: true,
  34. midClick: true,
  35. fixedContentPos: false,
  36. fixedBgPos: true
  37. });
  38. /* ========================================================================= */
  39. /* Portfolio Filtering Hook
  40. /* ========================================================================= */
  41. var containerEl = document.querySelector('.shuffle-wrapper');
  42. if (containerEl) {
  43. var Shuffle = window.Shuffle;
  44. var myShuffle = new Shuffle(document.querySelector('.shuffle-wrapper'), {
  45. itemSelector: '.shuffle-item',
  46. buffer: 1
  47. });
  48. jQuery('input[name="shuffle-filter"]').on('change', function (evt) {
  49. var input = evt.currentTarget;
  50. if (input.checked) {
  51. myShuffle.filter(input.value);
  52. }
  53. });
  54. }
  55. /* ========================================================================= */
  56. /* Testimonial Carousel
  57. /* ========================================================================= */
  58. $("#testimonials").slick({
  59. infinite: true,
  60. arrows: false,
  61. autoplay: true,
  62. autoplaySpeed: 4000
  63. });
  64. /* ========================================================================= */
  65. /* animation scroll js
  66. /* ========================================================================= */
  67. var html_body = $('html, body');
  68. $('nav a, .page-scroll').on('click', function () { //use page-scroll class in any HTML tag for scrolling
  69. if (location.pathname.replace(/^\//, '') === this.pathname.replace(/^\//, '') && location.hostname === this.hostname) {
  70. var target = $(this.hash);
  71. target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
  72. if (target.length) {
  73. html_body.animate({
  74. scrollTop: target.offset().top - 50
  75. }, 1500, 'easeInOutExpo');
  76. return false;
  77. }
  78. }
  79. });
  80. // easeInOutExpo Declaration
  81. jQuery.extend(jQuery.easing, {
  82. easeInOutExpo: function (x, t, b, c, d) {
  83. if (t === 0) {
  84. return b;
  85. }
  86. if (t === d) {
  87. return b + c;
  88. }
  89. if ((t /= d / 2) < 1) {
  90. return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
  91. }
  92. return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
  93. }
  94. });
  95. /* ========================================================================= */
  96. /* counter up
  97. /* ========================================================================= */
  98. function counter() {
  99. var oTop;
  100. if ($('.count').length !== 0) {
  101. oTop = $('.count').offset().top - window.innerHeight;
  102. }
  103. if ($(window).scrollTop() > oTop) {
  104. $('.count').each(function () {
  105. var $this = $(this),
  106. countTo = $this.attr('data-count');
  107. $({
  108. countNum: $this.text()
  109. }).animate({
  110. countNum: countTo
  111. }, {
  112. duration: 1000,
  113. easing: 'swing',
  114. step: function () {
  115. $this.text(Math.floor(this.countNum));
  116. },
  117. complete: function () {
  118. $this.text(this.countNum);
  119. }
  120. });
  121. });
  122. }
  123. }
  124. $(window).on('scroll', function () {
  125. counter();
  126. });
  127. });