jointrashposs/assets/js/parallax/index.ts

10 lines
272 B
TypeScript
Raw Normal View History

2023-07-08 19:23:27 +02:00
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 });
}
}