-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.js
executable file
·105 lines (91 loc) · 2.9 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
$(function ($) {
"use strict";
$(".Modern-Slider").slick({
autoplay: true,
speed: 1000,
slidesToShow: 1,
slidesToScroll: 1,
pauseOnHover: false,
dots: true,
fade: true,
pauseOnDotsHover: true,
cssEase: "linear",
// fade:true,
draggable: false,
prevArrow: "<button class=\"PrevArrow\"></button>",
nextArrow: "<button class=\"NextArrow\"></button>",
});
$("#nav-toggle").on("click", function (event) {
event.preventDefault();
$("#main-nav").toggleClass("open");
});
$(".tabgroup > div").hide();
$(".tabgroup > div:first-of-type").show();
$(".tabs a").click(function (e) {
e.preventDefault();
var $this = $(this),
tabgroup = "#" + $this.parents(".tabs").data("tabgroup"),
others = $this.closest("li").siblings().children("a"),
target = $this.attr("href");
others.removeClass("active");
$this.addClass("active");
$(tabgroup).children("div").hide();
$(target).show();
});
$(".owl-carousel").owlCarousel({
loop: true,
margin: 30,
responsiveClass: true,
responsive: {
0: {
items: 1,
nav: true
},
600: {
items: 2,
nav: false
},
1000: {
items: 3,
nav: true,
loop: false
}
}
});
var contentSection = $(".content-section, .main-banner");
var navigation = $("nav");
//when a nav link is clicked, smooth scroll to the section
navigation.on("click", "a", function (event) {
event.preventDefault(); //prevents previous event
smoothScroll($(this.hash));
});
//update navigation on scroll...
$(window).on("scroll", function () {
updateNavigation();
});
//...and when the page starts
updateNavigation();
function updateNavigation() {
contentSection.each(function () {
var sectionName = $(this).attr("id");
var navigationMatch = $("nav a[href=\"#" + sectionName + "\"]");
if (($(this).offset().top - $(window).height() / 2 < $(window).scrollTop()) &&
($(this).offset().top + $(this).height() - $(window).height() / 2 > $(window).scrollTop())) {
navigationMatch.addClass("active-section");
} else {
navigationMatch.removeClass("active-section");
}
});
}
function smoothScroll(target) {
$("body,html").animate({
scrollTop: target.offset().top
}, 800);
}
$(".button a[href*=\"#\"]").on("click", function (e) {
e.preventDefault();
$("html, body").animate({
scrollTop: $($(this).attr("href")).offset().top - 0
}, 500, "linear");
});
});