Big jobs usually go to the men who prove their ability to outgrow small ones.
Big jobs usually go to the men who prove their ability to outgrow small ones.
마우스 이펙트 - 마우스 따라다니기
language-html"><main>
<div class="cursor"></div>
<div class="cursor-follower"></div>
<article class="mouseCont">
<p>Big jobs <em>usually go to the men</em> who prove their ability to outgrow small ones.</p>
<h2>작은 일에서 성장할 능력이 있는 사람에게 <em>큰일이 주어</em>진다.</h2>
</article>
</main>
.mouseCont {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
color: #fff;
width: 100%;
height: 100vh;
overflow: hidden;
font-family: 'NEXONLv1Gothic';
cursor: none;
}
.mouseCont p {
font-size: 2.5vw;
line-height: 2.3;
font-weight: 300;
}
.mouseCont h2 {
font-size: 3vw;
font-weight: normal;
font-weight: 400;
}
.mouseCont em {
font-style: normal;
border-bottom: 0.2vw dashed orange;
color: orange
}
.cursor {
position: absolute;
left: 0;
top: 0;
width: 10px;
height: 10px;
border-radius: 50%;
z-index: 9999;
background-color: rgba(255, 255, 255, 0.1);
user-select: none;
pointer-events: none;
transition: transform 0.3s, opacity 0.2s;
}
.cursor.active {
opacity: .5;
transform: scale(0);
}
.cursor.show {
opacity: .5;
transform: scale(1);
background: rgba(255, 51, 0, 1);
}
.cursor-follower {
position: absolute;
width: 30px;
height: 30px;
background: rgba(255, 255, 255, 0.3);
border-radius: 50%;
user-select: none;
pointer-events: none;
transition: transform 0.6s ease-in-out, opacity 0.2s ease-in-out;
}
.cursor-follower.active {
transform: scale(5);
background: rgba(255, 166, 0, 0.6);
}
.cursor-follower.show {
transform: scale(5);
background: rgba(255, 51, 0, 0.6);
}
.info,
.info a {
cursor: none;
}
const cursor = document.querySelector(".cursor");
const follower = document.querySelector(".cursor-follower");
//움직임 효과
document.addEventListener("mousemove", (e) => {
//cursor.style.left = e.pageX -5 + "px";
//cursor.style.top = e.pageY -5 + "px";
// let x1 = e.pageX - 5 + "px";
// let y1 = e.pageY - 5 + "px";
// let x2 = e.pageX - 15 + "px";
// let y2 = e.pageY - 15 + "px";
// cursor.style.cssText = "left:" + x1 + "; top:" + y1;
// follower.style.cssText = "left:" + x2 + "; top:" + y2;
gsap.to(cursor, {duration: 0.3, left: e.pageX - 5, top: e.pageY - 5 });
gsap.to(follower, {duration: 0.8, left: e.pageX - 15, top: e.pageY - 15 });
//오버 효과
document.querySelectorAll(".mouseCont em").forEach(em => {
em.addEventListener("mouseenter", () => {
cursor.classList.add("active");
follower.classList.add("active");
});
em.addEventListener("mouseleave", () => {
cursor.classList.remove("active");
follower.classList.remove("active");
})
});
//오버 효과2
document.querySelectorAll(".info").forEach(em => {
em.addEventListener("mouseenter", () => {
cursor.classList.add("show");
follower.classList.add("show");
});
em.addEventListener("mouseleave", () => {
cursor.classList.remove("show");
follower.classList.remove("show");
})
});
//출력용
document.querySelector(".pageX").innerText = e.pageX;
document.querySelector(".pageY").innerText = e.pageY;
})