Pain past is pleasure
지나간 고통은 쾌락이다
Pain past is pleasure
지나간 고통은 쾌락이다
마우스 이펙트 - 조명 효과
<main>
<section id="mouseType03">
<div class="cursor"></div>
<div class="mouse__wrap">
<p><span>Pain</span> past is <span>pleasure</span></p>
<p>지나간 <span>고통</span>은 <span>쾌락</span>이다</p>
</div>
</section>
</main>
body::before {
content: '';
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100vh;
background: rgba(0, 0, 0, 0.8);
z-index: -1;
}
.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 tomato;
color: tomato;
}
.cursor { /* 마우스를 따라다니는 원 */
position: absolute;
left: 0px;
top: 0px;
width: 200px;
height: 200px;
z-index: -1;
border-radius: 50%;
background-image: url(img/slide03.jpg);
background-size: cover;
background-position: center center;
background-attachment: fixed;
border: 5px solid #fff;
}
<script>
const circle3 = document.querySelector(".cursor").getBoundingClientRect();
//bottom: 200, height: 200, left: 0, right: 200, top: 0, width: 200, x: 0, y: 0
console.log(circle3)
//백그라운드와 마우스 커서의 이미지를 동일하게 한뒤에 백그라운드 포지션 어태치먼트 픽스드로 착시효과를 주는것
function follow(e){
gsap.to(".cursor", {duration: .3, left: e.pageX - (circle3.width)/2, top: e.pageY - (circle3.height)/2});
//출력용
document.querySelector(".pageX").innerHTML = e.pageX;
document.querySelector(".pageY").innerHTML = e.pageY;
}
window.addEventListener("mousemove", follow)
</script>