const arr = [1, 255, 639, 9, 7, 8, 5, 4, 2];
const task = (arr) => {
const len = arr.length;
let index = Math.round(Math.random() * (len -1));
const result = [];
const getNewItem = () => {
let curr = arr[index];
let prev = arr[index];
while (prev === curr) {
index = Math.round(Math.random() * (len -1));
curr = arr[index]
}
prev = curr;
return curr;
}
for (let i = 0; i < 50; i++) {
result.push(getNewItem());
}
return result;
}
https://codepen.io/EugeniaAntonova/pen/vYbjaxP?edi...
стили
.header {
height:80px;
width:100%;
position:sticky;
top:0;
left:0;
right:0;
z-index: 100;
background-color:rgba(0,0,0,0.3);
box-shadow: 0 10px 15px -5px rgba(0,0,0,.8);
transition: .5s ease transform;
}
скрипт
const header = document.querySelector('.header');
let lastScrollY = 0;
window.addEventListener('scroll', function() {
if (window.scrollY > lastScrollY) {
header.style.transform = 'translateY(-85px)';
} else {
header.style.transform = 'translateY(0px)';
}
lastScrollY = window.scrollY;
});
работает исправно