let figures__hover_1 = document.querySelector('.figures__hover-1');
let figures__hover_2 = document.querySelector('.figures__hover-2');
let figures__hover_3 = document.querySelector('.figures__hover-3');
document.querySelector('.what-we-do__li-1').addEventListener("mouseover", function () {
figures__hover_1.style.top = "100px";
figures__hover_2.style.top = "-100px";
figures__hover_3.style.top = "200px";
figures__hover_1.style.transition = "0.5s";
figures__hover_2.style.transition = "0.5s";
figures__hover_3.style.transition = "0.5s";
this.addEventListener("mouseout", function () {
figures__hover_1.style.top = "0px";
figures__hover_2.style.top = "0px";
figures__hover_3.style.top = "190px";
});
});
document.querySelector('.what-we-do__li-2').addEventListener("mouseover", function () {
figures__hover_1.style.top = "200px";
figures__hover_2.style.top = "0px";
figures__hover_3.style.top = "-100px";
figures__hover_1.style.transition = "0.5s";
figures__hover_2.style.transition = "0.5s";
figures__hover_3.style.transition = "0.5s";
this.addEventListener("mouseout", function () {
figures__hover_1.style.top = "0px";
figures__hover_2.style.top = "0px";
figures__hover_3.style.top = "190px";
});
});
// и так далее, таких блоков у меня восемь штук...
figures__hover_1.style.transition = "0.5s"; figures__hover_2.style.transition = "0.5s"; figures__hover_3.style.transition = "0.5s";
document.querySelector('.what-we-do__li-1').addEventListener("mouseover", function () { figures__hover_1.style.top = "100px"; figures__hover_2.style.top = "-100px"; figures__hover_3.style.top = "200px"; this.addEventListener("mouseout", function () { figures__hover_1.style.top = "0px"; figures__hover_2.style.top = "0px"; figures__hover_3.style.top = "190px"; }); });
mouseout
каждый раз при срабатывании mouseout
. А сотня mouseout
на одном элементе... Думаю, ты понял. element.addEventListener("mouseover", function () {
...
this.addEventListener("mouseout", function () { ... });
});
делать нельзя никогда. Это, простите - говно. mouseout
. 10 раз навели - 10 обработчиков висит и срабатывает по уводу мышки..figures__hover
где-то ниже .what-we-do__li
- полностью, иначе частично: в обработчике меняется только класс контейнера.mouseenter
и mouseleave
.