-
Notifications
You must be signed in to change notification settings - Fork 0
/
farmers.js
63 lines (51 loc) · 1.77 KB
/
farmers.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
const imageWrapper = document.querySelector('.image-wrapper')
const imageItems = document.querySelectorAll('.image-wrapper > *')
const imageLength = imageItems.length
const perView = 3
let totalScroll = 0
const delay = 3000
imageWrapper.style.setProperty('--per-view', perView)
for(let i = 0; i < perView; i++) {
imageWrapper.insertAdjacentHTML('beforeend', imageItems[i].outerHTML)
}
let autoScroll = setInterval(scrolling, delay)
function scrolling() {
totalScroll++
if(totalScroll == imageLength + 1) {
clearInterval(autoScroll)
totalScroll = 1
imageWrapper.style.transition = '0s'
imageWrapper.style.left = '0'
autoScroll = setInterval(scrolling, delay)
}
const widthEl = document.querySelector('.image-wrapper > :first-child').offsetWidth + 24
imageWrapper.style.left = `-${totalScroll * widthEl}px`
imageWrapper.style.transition = '2s'
}
function toggleBtn(){
let displayHandling = document.getElementById('profile_List')
if(displayHandling.style.display === 'flex'){
displayHandling.style.display = 'none'
} else{
displayHandling.style.display = 'flex'
}
}
var prevScrollpos = window.pageYOffset;
window.onscroll = function() {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos) {
document.querySelector("header").style.top = "0";
} else {
document.querySelector("header").style.top = "-7.2rem";
}
prevScrollpos = currentScrollPos;
}
const form = document.querySelector('.newsLetterForm');
const emailInput = form.querySelector('input[type="email"]');
form.addEventListener('submit', (event) => {
event.preventDefault();
const email = emailInput.value;
localStorage.setItem('newsletterEmail', email);
emailInput.value = '';
alert('You are now subscribed to our newsletter!');
});