
🍀 : 프로젝트에서 사용

// sc-product .group-product .img-area
$(document).mousemove(function(e){
xVal = e.clientX - window.innerWidth/2;
yVal = e.clientY - window.innerHeight/2;
gsap.to('.sc-product .group-product .prod', {
x:xVal/100,
y:yVal/100,
})
});

gsap.set('.sc-order1 .group-mask',{ 'mask-size': '200px', })
const order1 = gsap.timeline({
scrollTrigger:{
trigger: '.sc-order1',
start: '0% 50%',
end: '100% 100%',
// markers: true,
scrub: 0,
}
})
order1
.to({ value: 80 },1, {
value: 99.95,
duration: 0.5,
ease: "linear",
onUpdate: function () {
document.querySelector(".font-mono").textContent =
this.targets()[0].value.toFixed(2) + "%";
}
},'circle');
onUpdate(): 애니메이션이 진행될 때마다 실행된다.this.targets()[0].value: 현재 value 값을 가져온다..toFixed(2): 소수점 2자리까지 표시된다.document.querySelector(".font-mono").textContent = ....font-mono 요소의 텍스트를 현재 value 값으로 업데이트한다.
Draggable.create('.cursor-grab', {
type: 'y', // Y축으로만 드래그 가능
bounds: '.sc-info2 .group-design .drag-svg', // 드래그 범위 제한
onDrag: function () {
const boundsElement = document.querySelector('.sc-info2 .group-design .drag-svg'); // 실제 DOM 요소 가져오기
const handle = this.target.getBoundingClientRect(); // 드래그 요소 위치 가져오기
if (!boundsElement) return; // bounds 요소가 없으면 실행하지 않음
const bounds = boundsElement.getBoundingClientRect(); // 드래그 가능 범위 좌표 가져오기
const minY = bounds.top; // 최소 Y값
const maxY = bounds.bottom - handle.height; // 최대 Y값
const currentY = handle.top; // 현재 Y값
const progress = (currentY - minY) / (maxY - minY); // 진행도 (0 ~ 1)
gsap.to('.sc-info2 .group-design .lightOff', {
opacity: 1 - progress, // progress에 따라 1에서 0으로
duration: 0, // 즉시 반영 (실시간 업데이트)
});
}
});
.cursor-grab 요소가 Y축 방향으로만 드래그 가능하도록 한다..drag-svg 영역 내에서만 드래그 가능 (bounds로 제한)하도록 한다.currentY를 계산.progress 계산한다. (0,1로 볼 수 있음).lightOff 요소의 투명도를 조절한다..lightOff가 점점 투명해지고,