agex 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,8 @@
1
1
  (() => {
2
2
  let hasMoved = false;
3
+ let clickRippleEnabled = true;
4
+ let trailEnabled = false;
5
+ let trailPoints = [];
3
6
 
4
7
  function createCursor() {
5
8
  if (document.getElementById('agex-cursor')) return;
@@ -26,7 +29,30 @@
26
29
 
27
30
  const style = document.createElement('style');
28
31
  style.id = 'agex-cursor-style';
29
- style.textContent = ``;
32
+ style.textContent = `
33
+ .agex-cursor-ripple {
34
+ position: fixed;
35
+ border-radius: 50%;
36
+ background: rgba(255, 50, 50, 0.4);
37
+ pointer-events: none;
38
+ z-index: 2147483646;
39
+ transform: translate(-50%, -50%) scale(0);
40
+ animation: agex-ripple 0.4s ease-out forwards;
41
+ }
42
+ @keyframes agex-ripple {
43
+ to { transform: translate(-50%, -50%) scale(1); opacity: 0; }
44
+ }
45
+ .agex-cursor-trail {
46
+ position: fixed;
47
+ width: 8px;
48
+ height: 8px;
49
+ background: rgba(255, 50, 50, 0.3);
50
+ border-radius: 50%;
51
+ pointer-events: none;
52
+ z-index: 2147483645;
53
+ transform: translate(-50%, -50%);
54
+ }
55
+ `;
30
56
  document.head.appendChild(style);
31
57
 
32
58
  document.addEventListener('mousemove', (e) => {
@@ -38,14 +64,22 @@
38
64
  hasMoved = true;
39
65
  c.style.opacity = '1';
40
66
  }
67
+
68
+ if (trailEnabled) {
69
+ createTrailPoint(e.clientX, e.clientY);
70
+ }
41
71
  }
42
72
  }, true);
43
73
 
44
- document.addEventListener('mousedown', () => {
74
+ document.addEventListener('mousedown', (e) => {
45
75
  const c = document.getElementById('agex-cursor');
46
76
  if (c) {
47
77
  c.style.transform = 'translate(-50%, -50%) scale(0.8)';
48
78
  c.style.background = 'rgba(255, 200, 50, 1)';
79
+
80
+ if (clickRippleEnabled) {
81
+ createClickRipple(e.clientX, e.clientY);
82
+ }
49
83
  }
50
84
  }, true);
51
85
 
@@ -58,6 +92,76 @@
58
92
  }, true);
59
93
  }
60
94
 
95
+ function createClickRipple(x, y) {
96
+ const ripple = document.createElement('div');
97
+ ripple.className = 'agex-cursor-ripple';
98
+ ripple.style.left = `${x}px`;
99
+ ripple.style.top = `${y}px`;
100
+ ripple.style.width = '60px';
101
+ ripple.style.height = '60px';
102
+ document.body.appendChild(ripple);
103
+ setTimeout(() => ripple.remove(), 400);
104
+ }
105
+
106
+ function createTrailPoint(x, y) {
107
+ const point = document.createElement('div');
108
+ point.className = 'agex-cursor-trail';
109
+ point.style.left = `${x}px`;
110
+ point.style.top = `${y}px`;
111
+ document.body.appendChild(point);
112
+ trailPoints.push(point);
113
+
114
+ setTimeout(() => {
115
+ point.style.opacity = '0';
116
+ point.style.transition = 'opacity 0.3s';
117
+ }, 100);
118
+
119
+ setTimeout(() => {
120
+ point.remove();
121
+ trailPoints = trailPoints.filter(p => p !== point);
122
+ }, 400);
123
+ }
124
+
125
+ // Expose cursor configuration API
126
+ window.__agexCursor = {
127
+ setSize(size) {
128
+ const cursor = document.getElementById('agex-cursor');
129
+ if (!cursor) return;
130
+ const sizes = { normal: 16, large: 24, 'extra-large': 32 };
131
+ const s = sizes[size] || sizes.large;
132
+ cursor.style.width = `${s}px`;
133
+ cursor.style.height = `${s}px`;
134
+ },
135
+ setClickRipple(enabled) {
136
+ clickRippleEnabled = enabled;
137
+ },
138
+ setTrail(enabled) {
139
+ trailEnabled = enabled;
140
+ },
141
+ configure(options = {}) {
142
+ if (options.size) this.setSize(options.size);
143
+ if (options.clickRipple !== undefined) this.setClickRipple(options.clickRipple);
144
+ if (options.trail !== undefined) this.setTrail(options.trail);
145
+ },
146
+ sync() {
147
+ const cursor = document.getElementById('agex-cursor');
148
+ if (!cursor) return Promise.resolve('no cursor');
149
+ return new Promise(resolve => {
150
+ const handler = function(e) {
151
+ cursor.style.left = e.clientX + 'px';
152
+ cursor.style.top = e.clientY + 'px';
153
+ cursor.style.opacity = '1';
154
+ resolve('moved to ' + e.clientX + ',' + e.clientY);
155
+ };
156
+ document.addEventListener('mousemove', handler, { once: true });
157
+ setTimeout(function() {
158
+ document.removeEventListener('mousemove', handler);
159
+ resolve('hover complete');
160
+ }, 150);
161
+ });
162
+ }
163
+ };
164
+
61
165
  if (document.readyState === 'loading') {
62
166
  document.addEventListener('DOMContentLoaded', createCursor);
63
167
  } else {