티스토리 뷰
function follow(e){
// const circle = document.querySelector(".cursor").clientWidth; //190: border 값 빠진 상태
// const circle = document.querySelector(".cursor").offsetWidth; //200: border 값 포함 상태
const circle = document.querySelector(".cursor").getBoundingClientRect(); //bottom, height, left, right, top, width, x, y
// console.log(circle);
// console.log(circle.width);
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);
'Script Sample > Mouse Effect' 카테고리의 다른 글
Mouse Effect06 - 텍스트 효과 (0) | 2022.04.14 |
---|---|
Mouse Effect05 - 이미지효과2 (0) | 2022.02.25 |
Mouse Effect04 - 이미지효과 (0) | 2022.02.25 |
Mouse Effect02 - 따라다니기2 (0) | 2022.02.25 |
Mouse Effect01 - 따라다니기 (0) | 2022.02.24 |
댓글
© 2018 webstoryboy