-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path04.js
101 lines (97 loc) · 2.17 KB
/
04.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
import barbaCore from "https://cdn.skypack.dev/@barba/core";
import gsap from "https://cdn.skypack.dev/gsap";
import Swiper from "https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.mjs";
gsap.to(".loader-bar", {
yPercent: 100,
stagger: 0.05,
});
handleNavState();
barbaCore.init({
transitions: [
{
name: "loader-bars-transition",
leave(data) {
return gsap.to(".loader-bar", {
yPercent: 0,
stagger: 0.05,
});
},
enter(data) {
data.current.container.remove();
return gsap.to(".loader-bar", {
yPercent: 100,
stagger: 0.05,
});
},
},
],
views: [
{
namespace: "about",
beforeEnter(data) {
handleNavState();
handleInitAboutSlider();
},
},
{
namespace: "home",
beforeEnter(data) {
handleNavState();
},
},
{
namespace: "posts",
beforeEnter(data) {
handleNavState();
},
},
{
namespace: "posts-template",
beforeEnter(data) {
handleNavState();
},
},
],
});
function handleNavState() {
console.log("handleNavState");
const navLinks = document.querySelectorAll(".navbar_link");
navLinks.forEach((link) => {
link.classList.remove("is-active");
});
const currentPath = window.location.pathname;
const activeLink = document.querySelector(`a[href="${currentPath}"]`);
activeLink.classList.add("is-active");
}
function handleInitAboutSlider() {
const swiper = new Swiper(".wb-swiper", {
slideClass: "wb-swiper_slide",
wrapperClass: "wb-swiper_wrapper",
centeredSlides: true,
loop: true,
autoplay: {
delay: 3000,
disableOnInteraction: true,
},
pagination: {
el: ".wb-swiper_pagination",
bulletClass: "wb-swiper_bullet",
bulletActiveClass: "is-active",
clickable: true,
},
navigation: {
nextEl: `[wb-swiper="next"]`,
prevEl: `[wb-swiper="previous"]`,
},
breakpoints: {
480: {
slidesPerView: "auto",
spaceBetween: 36,
},
320: {
slidesPerView: "auto",
spaceBetween: 12,
},
},
});
}