Smooth Scroll
The content wrapper is position: fixed so it doesn’t scroll naturally. A .scroll-spacer div is sized to the wrapper’s scrollHeight, giving the page its scrollable distance. gsap.ticker.add() runs every animation frame: current += (window.scrollY - current) * 0.08 lerps the internal position, then gsap.set(wrapper, { y: -current }) applies it. Lower ease = dreamier, higher ease = snappier.
콘텐츠 래퍼는 position: fixed로 자연스럽게 스크롤되지 않습니다. .scroll-spacer div가 래퍼의 scrollHeight로 크기 지정됩니다. gsap.ticker.add()가 매 프레임 실행됩니다: current += (window.scrollY - current) * 0.08로 위치를 lerp하고 gsap.set(wrapper, { y: -current })로 적용합니다. 이징이 낮을수록 몽환적으로, 높을수록 빠릿하게 됩니다.
Source Code script.js
const wrapper = document.querySelector('.wrapper');
const spacer = document.querySelector('.scroll-spacer');
// Size the spacer to match the fixed wrapper so the page is scrollable
function resize() {
spacer.style.height = wrapper.scrollHeight + 'px';
}
resize();
window.addEventListener('resize', resize);
// Lerp current scroll position toward native scroll target each frame
let current = 0;
const ease = 0.08;
gsap.ticker.add(() => {
const target = window.scrollY;
current += (target - current) * ease;
gsap.set(wrapper, { y: -current });
});