The secret of getting ahead is getting started.
앞서가는 방법의 비밀은 시작하는 것이다.
The secret of getting ahead is getting started.
앞서가는 방법의 비밀은 시작하는 것이다.
마우스 이펙트 - 이미지 효과2
<main>
<section id="mouseType04">
<div class="cursor"></div>
<div class="mouse__wrap">
<div class="mouse__img">
<figure>
<img src="img/img04.jpg" alt="이미지">
</figure>
<figcaption>
<p>The secret of getting ahead is getting started.</p>
<p>앞서가는 방법의 비밀은 시작하는 것이다.</p>
</figcaption>
</div>
</div>
</section>
</main>
.mouse__wrap {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
color: #fff;
width: 100%;
height: 100vh;
overflow: hidden;
cursor: none;
}
.mouse__img {
position: relative;
text-align: center;
transform: rotateX(0deg) rotateY(0deg);
transform-style: preserve-3d;
will-change: transform;
}
.mouse__img figure {
width: 50vw;
position: relative;
}
.mouse__img figure::before {
content: '';
position: absolute;
left: 3%; bottom: -30px;
width: 95%;
height: 40px;
z-index: -1;
background: url(img/img07.jpg) center center no-repeat;
background-size: 100% 40px;
filter: blur(15px);
opacity: 0.9;
}
.mouse__img figcaption {
position: absolute;
left: 50%; top: 50%;
font-size: 1vw;
white-space: nowrap;
line-height: 1.6;
background: rgba(0, 0, 0, 0.4);
padding: 1vw 2vw;
transform: translate3d(-50%, -50%, 150px);
}
.cursor {
position: absolute;
left: 0; top: 0;
width: 100px;
height: 100px;
background: #fff;
border-radius: 50%;
z-index: 1000;
user-select: none;
pointer-events: none;
mix-blend-mode: difference;
}
const circle = document.querySelector(".cursor").getBoundingClientRect();
function mouseMove(e){
let mousePageX = e.pageX;
let mousePageY = e.pageY;
let centerPageX = window.innerWidth / 2 - mousePageX
let centerPageY = window.innerHeight / 2 - mousePageY
let maxPageX = Math.max(-50, Math.min(50, centerPageX));
let maxPageY = Math.max(-50, Math.min(50, centerPageY));
let anglepageX = maxPageX * 0.12
let anglepageY = maxPageY * 0.12
let softPageX = 0;
let softPageY = 0;
softPageX += (anglepageX - softPageX) * 0.6;
softPageY += (anglepageY - softPageY) * 0.6;
const imgMove = document.querySelector(".mouse__img");
imgMove.style.transform = "perspective(600px) rotateX("+softPageY+"deg) rotateY("+ -softPageX+"deg)"
let circleWidth = mousePageX - circle.width/2;
let circleHeight = mousePageY - circle.height/2
gsap.to(".cursor", {duration: 0.3, left: circleWidth, top: circleHeight})
document.querySelector(".mousePageX").textContent = mousePageX
document.querySelector(".mousePageY").textContent = mousePageY
document.querySelector(".centerPageX").textContent = centerPageX
document.querySelector(".centerPageY").textContent = centerPageY
document.querySelector(".maxPageX").textContent = maxPageX
document.querySelector(".maxPageY").textContent = maxPageY
}
document.addEventListener("mousemove", mouseMove)