if (isThis.style.backgroundImage == target.parentNode.querySelector(".face").style.backgroundImage){
let linkvariable = isThis;
setTimeout(() => linkvariable .parentNode.remove(), 1000);
setTimeout(() => target.parentNode.remove(), 1000);
isThis = undefined;
}
setTimeout((() => isThis.parentNode.remove())(), 1000);
isThis = undefined; // отрабатывал быстрее чем setTimout когда твой setTimout был без IIFE
setTimeout(() => {
isThis.parentNode.remove();
isThis = undefined;
}, 1000);
if (isThis.style.backgroundImage == target.parentNode.querySelector(".face").style.backgroundImage){
setTimeout(() => {
isThis.parentNode.remove();
isThis = undefined;
}, 1000);
setTimeout(() => target.parentNode.remove(), 1000);
}
20 или 30
for(const inf of obj){
let d = document.createElement("div");
for (const [key, value] of Object.entries(inf)) {
d.dataset.[key] = value;
}
}
Почему во всех статья рекомендуют сохранять access токен фронт в куках и потом прикреплять к запросам к API в заголовках, а не так как я описал выше?не знаю кто там чё рекомендует, но доступа к кукам с фронта нет если куки установлены с флагом httpOnly
const targetNavbarDesktop = document.querySelector('.fixed-navbar-desktop');
const targetNavbarMobile = document.querySelector('.fixed-navbar-mobile');
const fixedNavbarDesktop = document.querySelector('.navbar');
const fixedNavbarMobile = document.querySelector('.navbar');
const obFixedNavbar = new IntersectionObserver(obCallback);
let previousY = 0;
let previousRatio = 0
function obCallback(payload) {
const currentY = payload[0].boundingClientRect.y;
const currentRatio = payload[0].intersectionRatio
const isIntersecting = payload[0].isIntersecting;
if (currentY < previousY && isIntersecting) {
document.querySelector('.header').style.marginBottom = fixedNavbarMobile.offsetHeight + 'px';
fixedNavbarMobile.classList.add('navbar_fixed');
if (currentRatio < previousRatio) {
fixedNavbarMobile.classList.add('scroll-up'); // Появится при скролле вверх
}
} else if(currentY > previousY && isIntersecting) {
if(currentRatio > previousRatio){
fixedNavbarMobile.classList.remove('scroll-up');
}
}
previousY = currentY
previousRatio = currentRatio
}
if (document.documentElement.clientWidth > 992) {
obFixedNavbar.observe(targetNavbarDesktop);
} else {
obFixedNavbar.observe(targetNavbarMobile);
}
<div class="block">
<div class="box">
<div class='image'></div>
<div class="info">
<div class="fav-icon"></div>
</div>
</div>
<div class="box">
<div class='image'></div>
<div class="info">
<div class="fav-icon"></div>
</div>
</div>
<div class="box">
<div class='image'></div>
<div class="info">
<div class="fav-icon"></div>
</div>
</div>
</div>
.block {
display: grid;
grid-auto-rows: 100px;
gap: 20px;
margin: 0 auto;
padding: 20px;
width: 500px;
border: 1px solid black;
height: 500px;
}
.box {
display: flex;
width: 100%;
border: 1px solid black;
margin: 0 auto;
background-color: lightblue;
}
.box:nth-child(odd) {
flex-direction: row-reverse;
}
.image {
width: 30%;
height: 100%;
background-color: lightgreen;
}
.image:nth-child(odd) {
right: 620px;
}
.info{
width: 100%;
height: 100%;
position: relative;
}
.fav-icon{
width: 20px;
height: 20px;
background-color: white;
position: absolute;
right: 0;
top: 0;
}