티스토리 뷰
<div id="wrapper">
<div id="cursor"></div>
</div>
#wrapper{
overflow-x: hidden;
position: relative;
}
/* cursor */
#cursor{
position: absolute;
z-index: 10000;
pointer-events: none;
}
#cursor:after{
display: block;
content: '';
position: absolute;
width: 30px;
height: 30px;
border-radius: 50%;
background-color: #f00;
filter: drop-shadow(0 0 2px rgba(255,0,0,0.7)) drop-shadow(0 0 5px rgba(255,0,0,0.7)) drop-shadow(0 0 15px rgba(255,0,0,0.7));
-webkit-transition: 0.3s;
transition: 0.3s;
}
#cursor.on:after{
-webkit-transform: scale(2);
transform: scale(2);
}
function cursor(){
const cursor = document.getElementById('cursor');
let mouseX = 0;
let mouseY = 0;
let cursorX = 0;
let cursorY = 0;
let speed = 0.1;
function animate() {
let distX = mouseX - cursorX;
let distY = mouseY - cursorY;
cursorX = cursorX + (distX * speed);
cursorY = cursorY + (distY * speed);
cursor.style.left = cursorX + 'px';
cursor.style.top = cursorY + 'px';
requestAnimationFrame(animate);
}
animate();
document.body.addEventListener('mousemove', function(e){
mouseX = e.pageX - 10;
mouseY = e.pageY - 10;
})
}
function cursorPoint(){
var hoverBtn = $('.js_btn_hover_ani');
hoverBtn.on('mouseover', function(){
$('#cursor').addClass('on')
});
hoverBtn.on('mouseleave', function(){
$('#cursor').removeClass('on')
});
}
'WebPublisher > Interactive' 카테고리의 다른 글
마우스 진입 방향에 따라 배경이 슬라이딩 교체되는 hover (0) | 2024.02.19 |
---|---|
페이지 로딩 시 scroll top 값 조정 (0) | 2023.10.25 |
LasVegas Neon Sign 라스베이거스 네온사인 효과 (1) | 2023.10.24 |
Gift box wiggling and jump 선물상자 hover animation (0) | 2023.10.23 |
Fireworks 불꽃놀이 javascript 인터랙션 (0) | 2023.10.23 |
공지사항