diff --git a/resources/js/app.js b/resources/js/app.js index b1cbbab..3fe16df 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -15,14 +15,21 @@ document.addEventListener('DOMContentLoaded', () => { }); }); -const cursor = document.getElementById('custom-cursor'); +window.addEventListener('load', () => { + const cursor = document.getElementById('custom-cursor'); + const gsapInstance = window.gsap; -document.addEventListener('mousemove', (e) => { - gsap.to(cursor, { - duration: 0.2, - x: e.clientX + 20, - y: e.clientY - 15, - ease: 'power2.out' + if (!cursor || !gsapInstance) { + return; + } + + document.addEventListener('mousemove', (e) => { + gsapInstance.to(cursor, { + duration: 0.2, + x: e.clientX + 20, + y: e.clientY - 15, + ease: 'power2.out' + }); }); });