File size: 1,524 Bytes
8491f89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
(() => {
  // Keep native cursor on touch devices
  if ('ontouchstart' in window) return;

  // Hide the old dot and ring (blurry circle)
  const dot = document.getElementById('cursor-dot');
  const ring = document.getElementById('cursor-ring');
  if (dot) dot.style.display = 'none';
  if (ring) ring.style.display = 'none';

  // Create a simple white triangle cursor
  const cursor = document.createElement('div');
  cursor.style.position = 'fixed';
  cursor.style.left = '0';
  cursor.style.top = '0';
  cursor.style.width = '0';
  cursor.style.height = '0';
  cursor.style.pointerEvents = 'none';
  cursor.style.zIndex = '50';
  cursor.style.transition = 'transform 0.08s ease-out';
  cursor.innerHTML = `

    <svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">

      <!-- Classic arrow-style cursor pointing top-left -->

      <polygon points="1,1 1,21 6,16 9,22 12,21 9,15 19,15" fill="white" shape-rendering="crispEdges"/>

    </svg>

  `;
  document.body.appendChild(cursor);

  // Smooth follow
  let mx = window.innerWidth / 2;
  let my = window.innerHeight / 2;
  let ax = mx, ay = my;
  const lerp = (a, b, t) => a + (b - a) * t;

  function raf() {
    ax = lerp(ax, mx, 0.25);
    ay = lerp(ay, my, 0.25);
    cursor.style.transform = `translate(${ax}px, ${ay}px)`;
    requestAnimationFrame(raf);
  }
  requestAnimationFrame(raf);

  window.addEventListener('mousemove', (e) => {
    mx = e.clientX;
    my = e.clientY;
  });
})();