Clean up image file blueprint and remove cursor related functionalities

This commit is contained in:
Paul Nicoué 2025-05-01 17:14:24 +02:00
parent 58911e48d3
commit 776c8cb74e
10 changed files with 15 additions and 137 deletions

View file

@ -12,13 +12,9 @@ const body = document.body;
// SLIDER
const homeSection = document.querySelector('.home-section');
const navLinks = document.querySelectorAll('.navigation__link');
const socialLinks = document.querySelectorAll('.social__link');
const sliderSection = document.querySelector('.slider-section');
let slider;
const slides = document.querySelectorAll('.splide__slide');
let cursorOrientation;
let cursorColor;
// ----------------------------------------------------------------------------
// LOGIC
@ -88,86 +84,6 @@ function changeSlideOnSwipe() {
}
}
function turnSidebarLinksToWhite() {
if (navLinks) {
for (let i = 0; i < navLinks.length; i++) {
navLinks[i].classList.add('navigation__link--white');
}
}
if (socialLinks) {
for (let i = 0; i < socialLinks.length; i++) {
socialLinks[i].classList.add('social__link--white');
}
}
}
function turnSidebarLinksToBlack() {
if (navLinks) {
for (let i = 0; i < navLinks.length; i++) {
navLinks[i].classList.remove('navigation__link--white');
}
}
if (socialLinks) {
for (let i = 0; i < socialLinks.length; i++) {
socialLinks[i].classList.remove('social__link--white');
}
}
}
function editColorTheme(slide) {
if (slide) {
if (slide.getAttribute('data-text-color') === 'white') {
turnSidebarLinksToWhite();
cursorColor = 'light';
} else if (slide.getAttribute('data-text-color') === 'black') {
turnSidebarLinksToBlack();
cursorColor = 'dark';
}
if (body && cursorOrientation && cursorColor) {
if (cursorOrientation === 'previous') {
body.style.cursor = `url('/images/cursor-${cursorOrientation}-${cursorColor}.svg') 0 12, auto`;
} else if (cursorOrientation === 'next') {
body.style.cursor = `url('/images/cursor-${cursorOrientation}-${cursorColor}.svg') 24 12, auto`;
}
}
}
}
function editColorThemeOnSliderMounted() {
if (slider && slides) {
slider.on('mounted', function() {
editColorTheme(slides[0]);
})
}
}
function editColorThemeOnSlideActive() {
if (slider) {
slider.on('active', function(e) {
editColorTheme(e.slide);
});
}
}
function setCursorOnMove() {
if (body) {
body.addEventListener('mousemove', function(e) {
if (e.clientX >= window.innerWidth / 2) {
cursorOrientation = 'next';
} else {
cursorOrientation = 'previous';
}
if (cursorOrientation && cursorColor) {
if (cursorOrientation === 'previous') {
body.style.cursor = `url('/images/cursor-${cursorOrientation}-${cursorColor}.svg') 0 12, auto`;
} else if (cursorOrientation === 'next') {
body.style.cursor = `url('/images/cursor-${cursorOrientation}-${cursorColor}.svg') 24 12, auto`;
}
}
});
}
}
// ----------------------------------------------------------------------------
// PROGRAM
// ----------------------------------------------------------------------------
@ -179,9 +95,6 @@ enableActivePseudoClass();
// SLIDER
setUpSlider();
editColorThemeOnSliderMounted();
mountSlider();
changeSlideOnClick();
changeSlideOnSwipe();
editColorThemeOnSlideActive();
setCursorOnMove();