Every adventure requires a first step.
모든 모험은 첫 걸음이 필요해.
Every adventure requires a first step.
모든 모험은 첫 걸음이 필요해.
마우스 이펙트 - 조명 효과
<main>
<section id="mouseType03">
<div class="cursor"></div>
<div class="mouse__wrap">
<p>Every <span>adventure</span> requires a <span>first step</span>.</p>
<p>모든 <span>모험</span>은 <span>첫 걸음</span>이 필요해.</p>
</div>
</section>
</main>
body::before {
background: rgba(0, 0, 0, 0.6);
}
.mouse__wrap {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
color: #fff;
width: 100%;
height: 100vh;
overflow: hidden;
cursor: none;
}
.mouse__wrap p {
font-size: 2.5vw;
line-height: 2;
font-weight: 300;
}
.mouse__wrap p:last-child {
font-size: 3vw;
font-weight: 400;
}
.mouse__wrap p span {
border-bottom: 0.15vw dashed blueviolet;
color: blueviolet;
}
.cursor {
position: absolute;
left: -0;
top: -0;
width: 200px;
height: 200px;
z-index: -1;
border-radius: 50%;
background-image: url(img/img04.jpg);
background-size: cover;
background-position: center center;
background-attachment: fixed;
border: 5px solid #fff;
}
//요소값 알기
// const circle1 = document.querySelector(".cursor").clientWidth; //190 : border 빠진 상태
// const circle2 = document.querySelector(".cursor").offsetWidth; //200 : border 포함 상태
const circle = document.querySelector(".cursor").getBoundingClientRect(); //bottom height left right top width x y
function follow(e){
gsap.to(".cursor", {duration: .3, left: e.pageX -circle.width/2, top:e.pageY -circle.height/2 });
//출력용
document.querySelector(".pageX").innerText = e.pageX;
document.querySelector(".pageY").innerText = e.pageY;
}
window.addEventListener("mousemove",follow);