jointrashposs/assets/js/parallax/index.ts
2023-07-09 02:23:27 +09:00

10 lines
272 B
TypeScript

export const vParallax = {
mounted: (src: HTMLElement, binding: Ref<number>) => {
src.style.willChange = 'transform';
window.addEventListener('scroll', () => {
src.style.transform = `translateY(${window.scrollY / binding.value}px)`;
}, { passive: true });
}
}