@diabolic/pointy 1.0.0 â 1.0.2
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.
- package/README.md +187 -538
- package/dist/pointy.esm.js +128 -38
- package/dist/pointy.js +128 -38
- package/dist/pointy.min.js +1 -1
- package/dist/pointy.min.js.map +1 -1
- package/package.json +1 -1
- package/src/pointy.js +130 -40
package/README.md
CHANGED
|
@@ -1,69 +1,42 @@
|
|
|
1
|
-
# Pointy
|
|
1
|
+
# Pointy
|
|
2
2
|
|
|
3
3
|
A lightweight, dependency-free JavaScript library for creating animated tooltips with a pointing cursor. Perfect for product tours, onboarding flows, and feature highlights.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@diabolic/pointy)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
|
-
>
|
|
8
|
+
> [Live Demo](https://bugrakaan.github.io/pointy/)
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## Features
|
|
11
11
|
|
|
12
12
|
- ðŊ **Animated Pointer** - Smooth cursor animation with customizable SVG
|
|
13
13
|
- ð **Multi-step Tours** - Create guided product tours with multiple steps
|
|
14
14
|
- ðŽ **Multi-message Steps** - Each step can have multiple messages that auto-cycle
|
|
15
15
|
- ðŽ **Autoplay Mode** - Automatically advance through steps
|
|
16
16
|
- ðĻ **Customizable Styling** - CSS variables, custom class names, and SVG support
|
|
17
|
-
- ð **Target Tracking** - Follows target elements in real-time
|
|
17
|
+
- ð **Target Tracking** - Follows target elements in real-time
|
|
18
18
|
- âïļ **React Compatible** - Supports JSX/React elements as content
|
|
19
19
|
- ð **Event System** - Comprehensive events with group listeners
|
|
20
20
|
- ð **Smooth Animations** - 11 built-in easing presets
|
|
21
|
-
- ðą **Responsive** - Adapts to window resize and scroll
|
|
22
21
|
- ðŠķ **Lightweight** - Zero dependencies, ~15KB
|
|
23
22
|
|
|
24
|
-
##
|
|
23
|
+
## Installation
|
|
25
24
|
|
|
26
25
|
```bash
|
|
27
|
-
# npm
|
|
28
26
|
npm install @diabolic/pointy
|
|
29
|
-
|
|
30
|
-
# yarn
|
|
31
|
-
yarn add @diabolic/pointy
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
# pnpm
|
|
35
|
-
pnpm add @diabolic/pointy
|
|
36
27
|
```
|
|
37
28
|
|
|
38
29
|
### CDN
|
|
39
30
|
|
|
40
31
|
```html
|
|
41
|
-
<!-- UMD (Global variable) -->
|
|
42
32
|
<script src="https://unpkg.com/@diabolic/pointy/dist/pointy.min.js"></script>
|
|
43
|
-
|
|
44
|
-
<!-- Or from jsDelivr -->
|
|
45
|
-
<script src="https://cdn.jsdelivr.net/npm/@diabolic/pointy/dist/pointy.min.js"></script>
|
|
46
33
|
```
|
|
47
34
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
```html
|
|
51
|
-
<script src="pointy.js"></script>
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### Usage
|
|
35
|
+
## Quick Start
|
|
55
36
|
|
|
56
37
|
```javascript
|
|
57
|
-
// ES6 import
|
|
58
38
|
import Pointy from '@diabolic/pointy';
|
|
59
39
|
|
|
60
|
-
// CommonJS
|
|
61
|
-
const Pointy = require('@diabolic/pointy');
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## ð Quick Start
|
|
65
|
-
|
|
66
|
-
```javascript
|
|
67
40
|
const pointy = new Pointy({
|
|
68
41
|
steps: [
|
|
69
42
|
{ target: '#welcome-btn', content: 'Click here to get started!' },
|
|
@@ -72,99 +45,67 @@ const pointy = new Pointy({
|
|
|
72
45
|
]
|
|
73
46
|
});
|
|
74
47
|
|
|
75
|
-
|
|
76
48
|
pointy.show();
|
|
77
49
|
```
|
|
78
50
|
|
|
79
|
-
##
|
|
51
|
+
## Configuration
|
|
80
52
|
|
|
81
53
|
### Basic Options
|
|
82
54
|
|
|
83
55
|
| Option | Type | Default | Description |
|
|
84
56
|
|--------|------|---------|-------------|
|
|
85
57
|
| `steps` | `Array` | `[]` | Array of step objects |
|
|
86
|
-
| `target` | `string\|HTMLElement` | `null` | Initial target
|
|
87
|
-
| `content` | `string\|string[]` | `''` | Initial content (
|
|
58
|
+
| `target` | `string\|HTMLElement` | `null` | Initial target (single-step use) |
|
|
59
|
+
| `content` | `string\|string[]` | `''` | Initial content (single-step use) |
|
|
88
60
|
|
|
89
61
|
### Step Object
|
|
90
62
|
|
|
91
63
|
```javascript
|
|
92
64
|
{
|
|
93
65
|
target: '#element', // CSS selector or HTMLElement
|
|
94
|
-
content: 'Message', // String, HTML, array
|
|
95
|
-
direction: 'up', //
|
|
96
|
-
duration: 3000 //
|
|
66
|
+
content: 'Message', // String, HTML, array, or React element
|
|
67
|
+
direction: 'up', // 'up', 'down', or null (auto)
|
|
68
|
+
duration: 3000 // Step-specific autoplay duration (ms)
|
|
97
69
|
}
|
|
98
70
|
```
|
|
99
71
|
|
|
100
|
-
### Animation
|
|
72
|
+
### Animation
|
|
101
73
|
|
|
102
74
|
| Option | Type | Default | Description |
|
|
103
75
|
|--------|------|---------|-------------|
|
|
104
76
|
| `animationDuration` | `number` | `1000` | Move animation duration (ms) |
|
|
105
77
|
| `introFadeDuration` | `number` | `1000` | Initial fade-in duration (ms) |
|
|
106
|
-
| `bubbleFadeDuration` | `number` | `500` | Bubble fade
|
|
107
|
-
| `
|
|
108
|
-
| `
|
|
109
|
-
| `floatingAnimation` | `boolean` | `true` | Enable floating/bobbing animation |
|
|
78
|
+
| `bubbleFadeDuration` | `number` | `500` | Bubble fade duration (ms) |
|
|
79
|
+
| `easing` | `string` | `'default'` | Easing preset or cubic-bezier |
|
|
80
|
+
| `floatingAnimation` | `boolean` | `true` | Enable floating animation |
|
|
110
81
|
|
|
111
|
-
### Position
|
|
82
|
+
### Position
|
|
112
83
|
|
|
113
84
|
| Option | Type | Default | Description |
|
|
114
85
|
|--------|------|---------|-------------|
|
|
115
86
|
| `offsetX` | `number` | `20` | Horizontal offset from target |
|
|
116
87
|
| `offsetY` | `number` | `16` | Vertical offset from target |
|
|
117
|
-
| `initialPosition` | `string
|
|
118
|
-
| `initialPositionOffset` | `number` | `32` | Offset from edges for position presets |
|
|
119
|
-
| `resetPositionOnHide` | `boolean` | `false` | Reset position when hiding |
|
|
120
|
-
|
|
121
|
-
**Initial Position Presets:**
|
|
122
|
-
- `'center'` - Center of viewport
|
|
123
|
-
- `'top-left'`, `'top-center'`, `'top-right'`
|
|
124
|
-
- `'middle-left'`, `'middle-right'`
|
|
125
|
-
- `'bottom-left'`, `'bottom-center'`, `'bottom-right'`
|
|
126
|
-
- `'first-step'` - Start directly at first step's target (no intro animation)
|
|
127
|
-
- CSS selector (e.g., `'#my-element'`)
|
|
128
|
-
- HTMLElement reference
|
|
129
|
-
|
|
130
|
-
### Tracking Options
|
|
131
|
-
|
|
132
|
-
| Option | Type | Default | Description |
|
|
133
|
-
|--------|------|---------|-------------|
|
|
88
|
+
| `initialPosition` | `string` | `'center'` | Starting position preset |
|
|
134
89
|
| `tracking` | `boolean` | `true` | Enable real-time target tracking |
|
|
135
|
-
| `trackingFps` | `number` | `60` | Tracking frame rate (0 = unlimited) |
|
|
136
|
-
|
|
137
|
-
### Message Cycling Options
|
|
138
90
|
|
|
139
|
-
|
|
140
|
-
|--------|------|---------|-------------|
|
|
141
|
-
| `messageInterval` | `number\|null` | `null` | Auto-cycle messages interval (ms) |
|
|
142
|
-
|
|
143
|
-
### Autoplay Options
|
|
144
|
-
|
|
145
|
-
| Option | Type | Default | Description |
|
|
146
|
-
|--------|------|---------|-------------|
|
|
147
|
-
| `autoplay` | `number\|null` | `null` | Auto-advance interval (ms), null = manual |
|
|
148
|
-
| `autoplayEnabled` | `boolean` | `false` | Whether autoplay is initially enabled |
|
|
149
|
-
| `autoplayWaitForMessages` | `boolean` | `true` | Wait for all messages before advancing |
|
|
91
|
+
**Initial Position Presets:** `'center'`, `'top-left'`, `'top-center'`, `'top-right'`, `'middle-left'`, `'middle-right'`, `'bottom-left'`, `'bottom-center'`, `'bottom-right'`, `'first-step'`
|
|
150
92
|
|
|
151
|
-
###
|
|
93
|
+
### Autoplay
|
|
152
94
|
|
|
153
95
|
| Option | Type | Default | Description |
|
|
154
96
|
|--------|------|---------|-------------|
|
|
155
|
-
| `
|
|
156
|
-
| `
|
|
157
|
-
| `
|
|
97
|
+
| `autoplay` | `number\|null` | `null` | Auto-advance interval (ms) |
|
|
98
|
+
| `autoplayEnabled` | `boolean` | `false` | Start autoplay on show |
|
|
99
|
+
| `autoplayWaitForMessages` | `boolean` | `true` | Wait for all messages |
|
|
100
|
+
| `messageInterval` | `number\|null` | `null` | Message auto-cycle interval (ms) |
|
|
158
101
|
|
|
159
|
-
###
|
|
102
|
+
### Completion
|
|
160
103
|
|
|
161
104
|
| Option | Type | Default | Description |
|
|
162
105
|
|--------|------|---------|-------------|
|
|
163
|
-
| `
|
|
164
|
-
| `
|
|
165
|
-
| `
|
|
166
|
-
| `cssVarPrefix` | `string` | `classPrefix` | CSS variable prefix |
|
|
167
|
-
| `pointerSvg` | `string` | Built-in SVG | Custom SVG for pointer |
|
|
106
|
+
| `resetOnComplete` | `boolean` | `true` | Reset to initial position |
|
|
107
|
+
| `hideOnComplete` | `boolean` | `true` | Auto-hide after completion |
|
|
108
|
+
| `hideOnCompleteDelay` | `number\|null` | `null` | Delay before hide (ms) |
|
|
168
109
|
|
|
169
110
|
### Callbacks
|
|
170
111
|
|
|
@@ -173,7 +114,7 @@ pointy.show();
|
|
|
173
114
|
| `onStepChange` | `function(index, step)` | Called when step changes |
|
|
174
115
|
| `onComplete` | `function()` | Called when tour completes |
|
|
175
116
|
|
|
176
|
-
##
|
|
117
|
+
## Methods
|
|
177
118
|
|
|
178
119
|
### Lifecycle
|
|
179
120
|
|
|
@@ -181,7 +122,7 @@ pointy.show();
|
|
|
181
122
|
pointy.show(); // Show the pointer
|
|
182
123
|
pointy.hide(); // Hide the pointer
|
|
183
124
|
pointy.destroy(); // Remove and cleanup
|
|
184
|
-
pointy.restart(); // Restart from initial position
|
|
125
|
+
pointy.restart(); // Restart from initial position
|
|
185
126
|
```
|
|
186
127
|
|
|
187
128
|
### Navigation
|
|
@@ -189,66 +130,47 @@ pointy.restart(); // Restart from initial position with intro animation
|
|
|
189
130
|
```javascript
|
|
190
131
|
pointy.next(); // Go to next step
|
|
191
132
|
pointy.prev(); // Go to previous step
|
|
192
|
-
pointy.goToStep(index); // Go to specific step
|
|
133
|
+
pointy.goToStep(index); // Go to specific step
|
|
193
134
|
pointy.reset(); // Reset to initial position
|
|
194
|
-
pointy.reset(false); // Reset position without changing step
|
|
195
135
|
```
|
|
196
136
|
|
|
197
|
-
###
|
|
137
|
+
### Content
|
|
198
138
|
|
|
199
139
|
```javascript
|
|
200
|
-
//
|
|
201
|
-
pointy.
|
|
202
|
-
pointy.pointTo('#element', 'Custom message');
|
|
203
|
-
pointy.pointTo('#element', 'Message', 'down'); // Force direction
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
### Content Management
|
|
140
|
+
pointy.setMessages('New message'); // Replace all messages
|
|
141
|
+
pointy.setMessages(['Message 1', 'Message 2']); // Set multiple messages
|
|
207
142
|
|
|
208
|
-
|
|
209
|
-
pointy.setContent('New message');
|
|
210
|
-
pointy.setContent(['Message 1', 'Message 2', 'Message 3']);
|
|
211
|
-
pointy.setContent('<strong>HTML</strong> content');
|
|
212
|
-
|
|
213
|
-
pointy.nextMessage(); // Show next message
|
|
214
|
-
pointy.prevMessage(); // Show previous message
|
|
215
|
-
pointy.goToMessage(index); // Go to specific message
|
|
143
|
+
pointy.setMessage('Updated text'); // Update current message only
|
|
216
144
|
|
|
217
|
-
pointy.
|
|
218
|
-
pointy.
|
|
145
|
+
pointy.nextMessage();
|
|
146
|
+
pointy.prevMessage();
|
|
147
|
+
pointy.goToMessage(index);
|
|
219
148
|
```
|
|
220
149
|
|
|
221
|
-
###
|
|
150
|
+
### Point to Custom Target
|
|
222
151
|
|
|
223
152
|
```javascript
|
|
224
|
-
pointy.
|
|
225
|
-
pointy.
|
|
226
|
-
pointy.
|
|
227
|
-
pointy.pauseMessageCycle(); // Pause cycling
|
|
228
|
-
pointy.resumeMessageCycle(); // Resume cycling
|
|
229
|
-
|
|
230
|
-
pointy.isMessageCycleActive(); // Check if cycling
|
|
231
|
-
pointy.isMessageCyclePaused(); // Check if paused
|
|
153
|
+
pointy.pointTo('#element');
|
|
154
|
+
pointy.pointTo('#element', 'Custom message');
|
|
155
|
+
pointy.pointTo('#element', 'Message', 'down');
|
|
232
156
|
```
|
|
233
157
|
|
|
234
158
|
### Autoplay Control
|
|
235
159
|
|
|
236
160
|
```javascript
|
|
237
|
-
pointy.startAutoplay();
|
|
238
|
-
pointy.stopAutoplay();
|
|
239
|
-
pointy.pauseAutoplay();
|
|
240
|
-
pointy.resumeAutoplay();
|
|
241
|
-
|
|
242
|
-
pointy.isAutoplayActive(); // Check if autoplay is active
|
|
243
|
-
pointy.isAutoplayPaused(); // Check if autoplay is paused
|
|
161
|
+
pointy.startAutoplay();
|
|
162
|
+
pointy.stopAutoplay();
|
|
163
|
+
pointy.pauseAutoplay();
|
|
164
|
+
pointy.resumeAutoplay();
|
|
244
165
|
```
|
|
245
166
|
|
|
246
|
-
###
|
|
167
|
+
### Message Cycling
|
|
247
168
|
|
|
248
169
|
```javascript
|
|
249
|
-
pointy.
|
|
250
|
-
pointy.
|
|
251
|
-
pointy.
|
|
170
|
+
pointy.startMessageCycle();
|
|
171
|
+
pointy.stopMessageCycle();
|
|
172
|
+
pointy.pauseMessageCycle();
|
|
173
|
+
pointy.resumeMessageCycle();
|
|
252
174
|
```
|
|
253
175
|
|
|
254
176
|
### Setters
|
|
@@ -262,6 +184,7 @@ pointy.setAnimationDuration(800);
|
|
|
262
184
|
pointy.setIntroFadeDuration(500);
|
|
263
185
|
pointy.setBubbleFadeDuration(300);
|
|
264
186
|
pointy.setMessageTransitionDuration(400);
|
|
187
|
+
pointy.setFloatingAnimation(true);
|
|
265
188
|
|
|
266
189
|
// Position
|
|
267
190
|
pointy.setOffset(30, 20);
|
|
@@ -269,7 +192,7 @@ pointy.setInitialPosition('top-left');
|
|
|
269
192
|
pointy.setInitialPositionOffset(50);
|
|
270
193
|
|
|
271
194
|
// Tracking
|
|
272
|
-
pointy.setTracking(
|
|
195
|
+
pointy.setTracking(true);
|
|
273
196
|
pointy.setTrackingFps(30);
|
|
274
197
|
|
|
275
198
|
// Messages
|
|
@@ -277,323 +200,169 @@ pointy.setMessageInterval(2000);
|
|
|
277
200
|
|
|
278
201
|
// Autoplay
|
|
279
202
|
pointy.setAutoplayInterval(3000);
|
|
280
|
-
pointy.setAutoplayWaitForMessages(
|
|
203
|
+
pointy.setAutoplayWaitForMessages(true);
|
|
281
204
|
|
|
282
205
|
// Completion
|
|
283
|
-
pointy.setResetOnComplete(
|
|
206
|
+
pointy.setResetOnComplete(true);
|
|
284
207
|
pointy.setHideOnComplete(true);
|
|
285
208
|
pointy.setHideOnCompleteDelay(500);
|
|
286
209
|
|
|
287
210
|
// Styling
|
|
288
|
-
pointy.setFloatingAnimation(false);
|
|
289
211
|
pointy.setPointerSvg('<svg>...</svg>');
|
|
290
212
|
```
|
|
291
213
|
|
|
292
|
-
|
|
214
|
+
## Easing Presets
|
|
293
215
|
|
|
294
216
|
```javascript
|
|
295
|
-
pointy.
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
## ðĻ Easing Presets
|
|
299
|
-
|
|
300
|
-
```javascript
|
|
301
|
-
// Built-in presets
|
|
302
|
-
pointy.setEasing('default'); // Smooth deceleration (default)
|
|
217
|
+
pointy.setEasing('default'); // Smooth deceleration
|
|
303
218
|
pointy.setEasing('bounce'); // Bouncy overshoot
|
|
304
219
|
pointy.setEasing('elastic'); // Elastic spring
|
|
305
220
|
pointy.setEasing('smooth'); // Symmetric ease
|
|
306
221
|
pointy.setEasing('snap'); // Quick snap
|
|
307
|
-
|
|
308
|
-
// Material Design
|
|
309
|
-
pointy.setEasing('standard'); // Material standard
|
|
310
|
-
pointy.setEasing('decelerate'); // Material decelerate
|
|
311
|
-
pointy.setEasing('accelerate'); // Material accelerate
|
|
312
|
-
|
|
313
|
-
// Classic curves
|
|
314
222
|
pointy.setEasing('expo-out'); // Exponential out
|
|
315
|
-
pointy.setEasing('circ-out'); // Circular out
|
|
316
223
|
pointy.setEasing('back-out'); // Back out
|
|
317
224
|
|
|
318
|
-
// CSS built-ins
|
|
225
|
+
// CSS built-ins
|
|
319
226
|
pointy.setEasing('ease');
|
|
320
|
-
pointy.setEasing('ease-in-out');
|
|
321
227
|
pointy.setEasing('linear');
|
|
322
228
|
|
|
323
|
-
// Custom
|
|
229
|
+
// Custom
|
|
324
230
|
pointy.setEasing('cubic-bezier(0.68, -0.55, 0.27, 1.55)');
|
|
325
231
|
```
|
|
326
232
|
|
|
327
|
-
|
|
328
|
-
```javascript
|
|
329
|
-
Pointy.getEasingPresets();
|
|
330
|
-
// ['default', 'standard', 'decelerate', 'accelerate', 'bounce', 'elastic', ...]
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
## ðĄ Events
|
|
334
|
-
|
|
335
|
-
### Event System
|
|
233
|
+
## Events
|
|
336
234
|
|
|
337
235
|
```javascript
|
|
338
|
-
|
|
339
|
-
pointy.on('
|
|
340
|
-
|
|
341
|
-
});
|
|
236
|
+
pointy.on('show', (data) => console.log('Shown!'));
|
|
237
|
+
pointy.on('stepChange', (data) => console.log(data.toIndex));
|
|
238
|
+
pointy.on('complete', (data) => console.log('Done!'));
|
|
342
239
|
|
|
343
240
|
// Unsubscribe
|
|
344
|
-
const handler = (data) => console.log(data);
|
|
345
|
-
pointy.on('stepChange', handler);
|
|
346
241
|
pointy.off('stepChange', handler);
|
|
347
|
-
|
|
348
|
-
// Remove all listeners for an event
|
|
349
|
-
pointy.off('stepChange');
|
|
350
|
-
|
|
351
|
-
// Chaining
|
|
352
|
-
pointy.on('show', fn1).on('hide', fn2).on('complete', fn3);
|
|
353
242
|
```
|
|
354
243
|
|
|
355
244
|
### Event Groups
|
|
356
245
|
|
|
357
|
-
Listen to multiple related events
|
|
246
|
+
Listen to multiple related events at once:
|
|
358
247
|
|
|
359
248
|
```javascript
|
|
360
|
-
// Listen to all lifecycle events
|
|
361
249
|
pointy.on('lifecycle', (data) => {
|
|
362
|
-
|
|
250
|
+
// Fires for: show, hide, destroy, restart, reset
|
|
251
|
+
console.log(data.type);
|
|
363
252
|
});
|
|
364
253
|
|
|
365
|
-
// Listen to all navigation events
|
|
366
254
|
pointy.on('navigation', (data) => {
|
|
367
|
-
|
|
255
|
+
// Fires for: stepChange, next, prev, complete
|
|
368
256
|
});
|
|
369
257
|
|
|
370
|
-
// Listen to ALL events
|
|
371
258
|
pointy.on('all', (data) => {
|
|
372
|
-
|
|
259
|
+
// Fires for ALL events
|
|
373
260
|
});
|
|
374
|
-
|
|
375
|
-
// or
|
|
376
|
-
pointy.on('*', (data) => { ... });
|
|
377
|
-
```
|
|
378
|
-
|
|
379
|
-
**Available Groups:**
|
|
380
|
-
| Group | Events |
|
|
381
|
-
|-------|--------|
|
|
382
|
-
| `lifecycle` | beforeShow, show, beforeHide, hide, destroy, beforeRestart, restart, beforeReset, reset |
|
|
383
|
-
| `navigation` | beforeStepChange, stepChange, next, prev, complete |
|
|
384
|
-
| `animation` | animationStart, animationEnd, move, moveComplete, introAnimationStart, introAnimationEnd |
|
|
385
|
-
| `content` | contentSet, messagesSet, messageChange |
|
|
386
|
-
| `messageCycle` | messageCycleStart, messageCycleStop, messageCyclePause, messageCycleResume, messageCycleComplete |
|
|
387
|
-
| `pointing` | beforePointTo, pointTo, pointToComplete |
|
|
388
|
-
| `tracking` | track, targetChange, trackingChange, trackingFpsChange |
|
|
389
|
-
| `autoplay` | autoplayStart, autoplayStop, autoplayPause, autoplayResume, autoplayNext, autoplayComplete, autoHide |
|
|
390
|
-
| `config` | All `*Change` events |
|
|
391
|
-
|
|
392
|
-
### Static Helpers
|
|
393
|
-
|
|
394
|
-
```javascript
|
|
395
|
-
Pointy.getEventGroup('show'); // 'lifecycle'
|
|
396
|
-
Pointy.getEventsInGroup('lifecycle'); // ['beforeShow', 'show', ...]
|
|
397
|
-
Pointy.EVENT_GROUPS; // All groups object
|
|
398
261
|
```
|
|
399
262
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
|
406
|
-
|
|
407
|
-
| `
|
|
408
|
-
| `
|
|
409
|
-
| `
|
|
410
|
-
| `
|
|
411
|
-
| `
|
|
412
|
-
| `
|
|
413
|
-
| `
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
|
419
|
-
|
|
420
|
-
| `
|
|
421
|
-
| `
|
|
422
|
-
| `
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
|
428
|
-
|
|
429
|
-
| `
|
|
430
|
-
| `
|
|
431
|
-
| `
|
|
432
|
-
| `
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
|
438
|
-
|
|
439
|
-
| `
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
|
445
|
-
|
|
446
|
-
| `
|
|
447
|
-
| `
|
|
448
|
-
| `
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
|
454
|
-
|
|
455
|
-
| `
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
|
461
|
-
|
|
462
|
-
| `
|
|
463
|
-
| `
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
|
469
|
-
|
|
470
|
-
| `
|
|
471
|
-
| `
|
|
472
|
-
| `
|
|
473
|
-
| `
|
|
474
|
-
| `
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
- `initialPositionChange`, `initialPositionOffsetChange`
|
|
483
|
-
- `autoplayChange`, `autoplayWaitForMessagesChange`, `pointerSvgChange`
|
|
484
|
-
|
|
485
|
-
## ðĻ CSS Customization
|
|
263
|
+
**Available Groups:** `lifecycle`, `navigation`, `animation`, `content`, `messageCycle`, `pointing`, `tracking`, `autoplay`, `config`
|
|
264
|
+
|
|
265
|
+
### All Events
|
|
266
|
+
|
|
267
|
+
#### Lifecycle
|
|
268
|
+
| Event | Data |
|
|
269
|
+
|-------|------|
|
|
270
|
+
| `beforeShow` | `{ target }` |
|
|
271
|
+
| `show` | `{ target, isIntro, isFirstStep? }` |
|
|
272
|
+
| `beforeHide` | `{ target }` |
|
|
273
|
+
| `hide` | `{ target }` |
|
|
274
|
+
| `destroy` | `{}` |
|
|
275
|
+
| `beforeRestart` | `{}` |
|
|
276
|
+
| `restart` | `{}` |
|
|
277
|
+
| `beforeReset` | `{ currentStep }` |
|
|
278
|
+
| `reset` | `{ stepIndex }` |
|
|
279
|
+
|
|
280
|
+
#### Navigation
|
|
281
|
+
| Event | Data |
|
|
282
|
+
|-------|------|
|
|
283
|
+
| `beforeStepChange` | `{ fromIndex, toIndex, step, fromTarget }` |
|
|
284
|
+
| `stepChange` | `{ fromIndex, toIndex, step, target }` |
|
|
285
|
+
| `next` | `{ fromIndex, toIndex }` |
|
|
286
|
+
| `prev` | `{ fromIndex, toIndex }` |
|
|
287
|
+
| `complete` | `{ totalSteps, source }` |
|
|
288
|
+
|
|
289
|
+
#### Animation
|
|
290
|
+
| Event | Data |
|
|
291
|
+
|-------|------|
|
|
292
|
+
| `animationStart` | `{ fromTarget, toTarget, type, stepIndex? }` |
|
|
293
|
+
| `animationEnd` | `{ fromTarget, toTarget, type, stepIndex? }` |
|
|
294
|
+
| `move` | `{ index, step }` |
|
|
295
|
+
| `moveComplete` | `{ index, step, target }` |
|
|
296
|
+
| `introAnimationStart` | `{ duration, initialPosition }` |
|
|
297
|
+
| `introAnimationEnd` | `{ initialPosition }` |
|
|
298
|
+
|
|
299
|
+
#### Content
|
|
300
|
+
| Event | Data |
|
|
301
|
+
|-------|------|
|
|
302
|
+
| `messagesSet` | `{ messages, total, animated, cyclePaused }` |
|
|
303
|
+
| `messageUpdate` | `{ index, message, oldMessage, total, animated }` |
|
|
304
|
+
| `messageChange` | `{ fromIndex, toIndex, message, total, isAuto? }` |
|
|
305
|
+
|
|
306
|
+
#### Message Cycle
|
|
307
|
+
| Event | Data |
|
|
308
|
+
|-------|------|
|
|
309
|
+
| `messageCycleStart` | `{ interval, totalMessages }` |
|
|
310
|
+
| `messageCycleStop` | `{ currentIndex }` |
|
|
311
|
+
| `messageCyclePause` | `{ currentIndex }` |
|
|
312
|
+
| `messageCycleResume` | `{ currentIndex }` |
|
|
313
|
+
| `messageCycleComplete` | `{ stepIndex, totalMessages }` |
|
|
314
|
+
|
|
315
|
+
#### Pointing
|
|
316
|
+
| Event | Data |
|
|
317
|
+
|-------|------|
|
|
318
|
+
| `beforePointTo` | `{ target, content, direction, fromTarget }` |
|
|
319
|
+
| `pointTo` | `{ target, content, direction }` |
|
|
320
|
+
| `pointToComplete` | `{ target, content }` |
|
|
321
|
+
|
|
322
|
+
#### Tracking
|
|
323
|
+
| Event | Data |
|
|
324
|
+
|-------|------|
|
|
325
|
+
| `track` | `{ target, timestamp }` |
|
|
326
|
+
| `targetChange` | `{ from, to }` |
|
|
327
|
+
| `trackingChange` | `{ from, to }` |
|
|
328
|
+
| `trackingFpsChange` | `{ from, to }` |
|
|
329
|
+
|
|
330
|
+
#### Autoplay
|
|
331
|
+
| Event | Data |
|
|
332
|
+
|-------|------|
|
|
333
|
+
| `autoplayStart` | `{}` |
|
|
334
|
+
| `autoplayStop` | `{}` |
|
|
335
|
+
| `autoplayPause` | `{}` |
|
|
336
|
+
| `autoplayResume` | `{}` |
|
|
337
|
+
| `autoplayNext` | `{ fromIndex, duration?, afterMessages? }` |
|
|
338
|
+
| `autoplayComplete` | `{ totalSteps }` |
|
|
339
|
+
| `autoHide` | `{ delay, source }` |
|
|
340
|
+
|
|
341
|
+
#### Config
|
|
342
|
+
All setter methods emit `*Change` events with `{ from, to }` data.
|
|
343
|
+
|
|
344
|
+
## CSS Customization
|
|
486
345
|
|
|
487
346
|
### CSS Variables
|
|
488
347
|
|
|
489
348
|
```css
|
|
490
349
|
.pointy-container {
|
|
491
|
-
--pointy-duration: 1000ms;
|
|
492
|
-
--pointy-easing: cubic-bezier(0, 0.55, 0.45, 1);
|
|
493
|
-
--pointy-bubble-fade: 500ms;
|
|
350
|
+
--pointy-duration: 1000ms;
|
|
351
|
+
--pointy-easing: cubic-bezier(0, 0.55, 0.45, 1);
|
|
352
|
+
--pointy-bubble-fade: 500ms;
|
|
494
353
|
}
|
|
495
354
|
```
|
|
496
355
|
|
|
497
|
-
### Custom Class Prefix
|
|
498
|
-
|
|
499
|
-
```javascript
|
|
500
|
-
const pointy = new Pointy({
|
|
501
|
-
classPrefix: 'my-tooltip', // Uses: my-tooltip-container, my-tooltip-pointer, etc.
|
|
502
|
-
cssVarPrefix: 'tooltip', // Uses: --tooltip-duration, etc.
|
|
503
|
-
steps: [...]
|
|
504
|
-
});
|
|
505
|
-
```
|
|
506
|
-
|
|
507
|
-
### Generated Classes
|
|
508
|
-
|
|
509
|
-
| Class | Description |
|
|
510
|
-
|-------|-------------|
|
|
511
|
-
| `{prefix}-container` | Main container element |
|
|
512
|
-
| `{prefix}-pointer` | Pointer/cursor element |
|
|
513
|
-
| `{prefix}-bubble` | Tooltip bubble |
|
|
514
|
-
| `{prefix}-bubble-text` | Text inside bubble |
|
|
515
|
-
| `{prefix}-hidden` | Applied when hidden |
|
|
516
|
-
| `{prefix}-visible` | Applied when visible |
|
|
517
|
-
| `{prefix}-moving` | Applied during animation |
|
|
518
|
-
|
|
519
356
|
### Custom Pointer SVG
|
|
520
357
|
|
|
521
358
|
```javascript
|
|
522
359
|
const pointy = new Pointy({
|
|
523
|
-
pointerSvg:
|
|
524
|
-
<svg width="40" height="40" viewBox="0 0 40 40">
|
|
525
|
-
<circle cx="20" cy="20" r="15" fill="#ff6b6b"/>
|
|
526
|
-
</svg>
|
|
527
|
-
`,
|
|
360
|
+
pointerSvg: `<svg width="40" height="40">...</svg>`,
|
|
528
361
|
steps: [...]
|
|
529
362
|
});
|
|
530
|
-
|
|
531
|
-
// Or change at runtime
|
|
532
|
-
pointy.setPointerSvg('<svg>...</svg>');
|
|
533
363
|
```
|
|
534
364
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
```jsx
|
|
538
|
-
// Use React elements as pointer SVG
|
|
539
|
-
const CustomPointer = () => (
|
|
540
|
-
<svg width="40" height="40" viewBox="0 0 40 40">
|
|
541
|
-
<circle cx="20" cy="20" r="15" fill="#ff6b6b"/>
|
|
542
|
-
</svg>
|
|
543
|
-
);
|
|
544
|
-
|
|
545
|
-
const pointy = new Pointy({
|
|
546
|
-
pointerSvg: <CustomPointer />,
|
|
547
|
-
steps: [...]
|
|
548
|
-
});
|
|
549
|
-
```
|
|
550
|
-
|
|
551
|
-
## âïļ React Integration
|
|
552
|
-
|
|
553
|
-
Pointy supports React elements as content and pointer SVG:
|
|
554
|
-
|
|
555
|
-
```jsx
|
|
556
|
-
const pointy = new Pointy({
|
|
557
|
-
steps: [
|
|
558
|
-
{
|
|
559
|
-
target: '#element',
|
|
560
|
-
content: <div><strong>Welcome!</strong> Click to continue</div>
|
|
561
|
-
},
|
|
562
|
-
{
|
|
563
|
-
target: '#features',
|
|
564
|
-
content: [
|
|
565
|
-
<span key="1">First message with <em>JSX</em></span>,
|
|
566
|
-
<span key="2">Second message</span>
|
|
567
|
-
]
|
|
568
|
-
}
|
|
569
|
-
]
|
|
570
|
-
});
|
|
571
|
-
```
|
|
572
|
-
|
|
573
|
-
## ð§ Static Methods
|
|
574
|
-
|
|
575
|
-
```javascript
|
|
576
|
-
// Render content (supports string/HTML and React elements)
|
|
577
|
-
Pointy.renderContent(element, content);
|
|
578
|
-
|
|
579
|
-
// Get DOM element from selector or element
|
|
580
|
-
Pointy.getTargetElement('#selector');
|
|
581
|
-
Pointy.getTargetElement(domElement);
|
|
582
|
-
|
|
583
|
-
// Generate class names with custom prefix
|
|
584
|
-
Pointy.generateClassNames('custom-prefix', { bubble: 'tooltip' });
|
|
585
|
-
|
|
586
|
-
// Get available presets
|
|
587
|
-
Pointy.getEasingPresets(); // ['default', 'bounce', ...]
|
|
588
|
-
Pointy.getInitialPositions(); // ['center', 'top-left', ...]
|
|
589
|
-
|
|
590
|
-
// Event group helpers
|
|
591
|
-
Pointy.getEventGroup('show'); // 'lifecycle'
|
|
592
|
-
Pointy.getEventsInGroup('navigation'); // ['stepChange', 'next', ...]
|
|
593
|
-
Pointy.EVENT_GROUPS; // All groups object
|
|
594
|
-
```
|
|
595
|
-
|
|
596
|
-
## ðĄ Examples
|
|
365
|
+
## Examples
|
|
597
366
|
|
|
598
367
|
### Basic Tour
|
|
599
368
|
|
|
@@ -602,11 +371,8 @@ const tour = new Pointy({
|
|
|
602
371
|
steps: [
|
|
603
372
|
{ target: '#logo', content: 'Welcome to our app!' },
|
|
604
373
|
{ target: '#dashboard', content: 'This is your dashboard' },
|
|
605
|
-
{ target: '#settings', content: 'Customize
|
|
606
|
-
]
|
|
607
|
-
onComplete: () => {
|
|
608
|
-
console.log('Tour completed!');
|
|
609
|
-
}
|
|
374
|
+
{ target: '#settings', content: 'Customize settings here' }
|
|
375
|
+
]
|
|
610
376
|
});
|
|
611
377
|
|
|
612
378
|
tour.show();
|
|
@@ -615,81 +381,39 @@ tour.show();
|
|
|
615
381
|
### Autoplay Tour
|
|
616
382
|
|
|
617
383
|
```javascript
|
|
618
|
-
const
|
|
384
|
+
const tour = new Pointy({
|
|
619
385
|
steps: [
|
|
620
386
|
{ target: '#step1', content: 'Step 1' },
|
|
621
|
-
{ target: '#step2', content: 'Step 2', duration: 5000 },
|
|
387
|
+
{ target: '#step2', content: 'Step 2', duration: 5000 },
|
|
622
388
|
{ target: '#step3', content: 'Step 3' }
|
|
623
389
|
],
|
|
624
|
-
autoplay: 3000,
|
|
625
|
-
autoplayEnabled: true,
|
|
626
|
-
hideOnComplete: true
|
|
627
|
-
hideOnCompleteDelay: 500 // Wait 500ms before hiding
|
|
628
|
-
});
|
|
629
|
-
|
|
630
|
-
autoTour.show();
|
|
631
|
-
```
|
|
632
|
-
|
|
633
|
-
### Multi-Message Steps with Auto-Cycle
|
|
634
|
-
|
|
635
|
-
```javascript
|
|
636
|
-
const multiMsg = new Pointy({
|
|
637
|
-
steps: [
|
|
638
|
-
{
|
|
639
|
-
target: '#feature',
|
|
640
|
-
content: [
|
|
641
|
-
'Did you know...',
|
|
642
|
-
'You can click this button',
|
|
643
|
-
'To access advanced features!'
|
|
644
|
-
]
|
|
645
|
-
}
|
|
646
|
-
],
|
|
647
|
-
messageInterval: 2500, // Change message every 2.5s
|
|
648
|
-
autoplay: null, // Manual navigation
|
|
649
|
-
autoplayWaitForMessages: true
|
|
650
|
-
});
|
|
651
|
-
|
|
652
|
-
multiMsg.show();
|
|
653
|
-
```
|
|
654
|
-
|
|
655
|
-
### Feature Highlight
|
|
656
|
-
|
|
657
|
-
```javascript
|
|
658
|
-
const highlight = new Pointy({
|
|
659
|
-
target: '#new-feature',
|
|
660
|
-
content: 'New! Check out this feature',
|
|
661
|
-
initialPosition: 'bottom-right',
|
|
662
|
-
floatingAnimation: true
|
|
390
|
+
autoplay: 3000,
|
|
391
|
+
autoplayEnabled: true,
|
|
392
|
+
hideOnComplete: true
|
|
663
393
|
});
|
|
664
394
|
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
// Point to different elements
|
|
668
|
-
highlight.pointTo('#another-element', 'Or explore this!');
|
|
395
|
+
tour.show();
|
|
669
396
|
```
|
|
670
397
|
|
|
671
|
-
###
|
|
398
|
+
### Multi-Message Steps
|
|
672
399
|
|
|
673
400
|
```javascript
|
|
674
|
-
const
|
|
675
|
-
steps: [
|
|
676
|
-
|
|
401
|
+
const tour = new Pointy({
|
|
402
|
+
steps: [{
|
|
403
|
+
target: '#feature',
|
|
404
|
+
content: [
|
|
405
|
+
'Did you know...',
|
|
406
|
+
'You can click this button',
|
|
407
|
+
'To access advanced features!'
|
|
408
|
+
]
|
|
409
|
+
}],
|
|
410
|
+
messageInterval: 2500
|
|
677
411
|
});
|
|
678
412
|
|
|
679
|
-
|
|
680
|
-
.on('show', () => console.log('Tour started'))
|
|
681
|
-
.on('stepChange', ({ toIndex }) => analytics.track('tour_step', toIndex))
|
|
682
|
-
.on('complete', ({ source }) => {
|
|
683
|
-
analytics.track('tour_complete', { source });
|
|
684
|
-
})
|
|
685
|
-
.on('autoHide', () => {
|
|
686
|
-
showFollowUpModal();
|
|
687
|
-
});
|
|
688
|
-
|
|
689
|
-
eventTour.show();
|
|
413
|
+
tour.show();
|
|
690
414
|
```
|
|
691
415
|
|
|
692
|
-
### Pause
|
|
416
|
+
### Pause on Hover
|
|
693
417
|
|
|
694
418
|
```javascript
|
|
695
419
|
const tour = new Pointy({
|
|
@@ -698,112 +422,37 @@ const tour = new Pointy({
|
|
|
698
422
|
autoplayEnabled: true
|
|
699
423
|
});
|
|
700
424
|
|
|
701
|
-
tour.
|
|
702
|
-
|
|
703
|
-
tour.pauseMessageCycle();
|
|
704
|
-
});
|
|
705
|
-
|
|
706
|
-
tour.bubble.addEventListener('mouseleave', () => {
|
|
707
|
-
tour.resumeAutoplay();
|
|
708
|
-
tour.resumeMessageCycle();
|
|
709
|
-
});
|
|
425
|
+
tour.container.addEventListener('mouseenter', () => tour.pauseAutoplay());
|
|
426
|
+
tour.container.addEventListener('mouseleave', () => tour.resumeAutoplay());
|
|
710
427
|
|
|
711
428
|
tour.show();
|
|
712
429
|
```
|
|
713
430
|
|
|
714
|
-
|
|
431
|
+
## TypeScript
|
|
715
432
|
|
|
716
|
-
|
|
717
|
-
const styledPointy = new Pointy({
|
|
718
|
-
classPrefix: 'custom',
|
|
719
|
-
steps: [
|
|
720
|
-
{ target: '#el', content: 'Styled tooltip!' }
|
|
721
|
-
],
|
|
722
|
-
pointerSvg: `
|
|
723
|
-
<svg width="24" height="24" viewBox="0 0 24 24">
|
|
724
|
-
<path d="M12 2L2 12l10 10V2z" fill="#6366f1"/>
|
|
725
|
-
</svg>
|
|
726
|
-
`
|
|
727
|
-
});
|
|
728
|
-
|
|
729
|
-
// Add custom CSS
|
|
730
|
-
const style = document.createElement('style');
|
|
731
|
-
style.textContent = `
|
|
732
|
-
.custom-bubble {
|
|
733
|
-
background: linear-gradient(135deg, #6366f1, #8b5cf6);
|
|
734
|
-
border-radius: 20px;
|
|
735
|
-
padding: 12px 20px;
|
|
736
|
-
}
|
|
737
|
-
`;
|
|
738
|
-
document.head.appendChild(style);
|
|
739
|
-
|
|
740
|
-
styledPointy.show();
|
|
741
|
-
```
|
|
742
|
-
|
|
743
|
-
## ð Browser Support
|
|
744
|
-
|
|
745
|
-
- Chrome 60+
|
|
746
|
-
- Firefox 55+
|
|
747
|
-
- Safari 12+
|
|
748
|
-
- Edge 79+
|
|
749
|
-
|
|
750
|
-
## ð TypeScript Support
|
|
751
|
-
|
|
752
|
-
Pointy includes full TypeScript definitions out of the box. No additional `@types` package needed.
|
|
433
|
+
Full TypeScript support included:
|
|
753
434
|
|
|
754
435
|
```typescript
|
|
755
|
-
import Pointy, { PointyOptions, PointyStep
|
|
436
|
+
import Pointy, { PointyOptions, PointyStep } from '@diabolic/pointy';
|
|
756
437
|
|
|
757
438
|
const options: PointyOptions = {
|
|
758
|
-
steps: [
|
|
759
|
-
{ target: '#btn', content: 'Click here!' }
|
|
760
|
-
],
|
|
761
|
-
autoplay: 3000
|
|
439
|
+
steps: [{ target: '#btn', content: 'Click!' }]
|
|
762
440
|
};
|
|
763
441
|
|
|
764
442
|
const pointy = new Pointy(options);
|
|
765
443
|
|
|
766
|
-
// Full type safety for events
|
|
767
444
|
pointy.on('stepChange', (data) => {
|
|
768
|
-
console.log(data.fromIndex, data.toIndex);
|
|
769
|
-
});
|
|
770
|
-
|
|
771
|
-
// Type-safe event groups
|
|
772
|
-
pointy.on('lifecycle', (data) => {
|
|
773
|
-
console.log(data.type); // 'beforeShow' | 'show' | 'hide' | ...
|
|
445
|
+
console.log(data.fromIndex, data.toIndex);
|
|
774
446
|
});
|
|
775
447
|
```
|
|
776
448
|
|
|
777
|
-
|
|
449
|
+
## Browser Support
|
|
778
450
|
|
|
779
|
-
|
|
780
|
-
import {
|
|
781
|
-
Pointy,
|
|
782
|
-
PointyOptions,
|
|
783
|
-
PointyStep,
|
|
784
|
-
PointyClassNames,
|
|
785
|
-
PointyInitialPosition,
|
|
786
|
-
PointyEasing,
|
|
787
|
-
PointyEvent,
|
|
788
|
-
PointyEventGroup,
|
|
789
|
-
PointyEventData,
|
|
790
|
-
PointyEventCallback,
|
|
791
|
-
// Event-specific data types
|
|
792
|
-
PointyLifecycleEventData,
|
|
793
|
-
PointyNavigationEventData,
|
|
794
|
-
PointyAnimationEventData,
|
|
795
|
-
PointyContentEventData,
|
|
796
|
-
PointyMessageCycleEventData,
|
|
797
|
-
PointyPointingEventData,
|
|
798
|
-
PointyTrackingEventData,
|
|
799
|
-
PointyAutoplayEventData,
|
|
800
|
-
PointyConfigChangeEventData,
|
|
801
|
-
} from '@diabolic/pointy';
|
|
802
|
-
```
|
|
451
|
+
Chrome 60+, Firefox 55+, Safari 12+, Edge 79+
|
|
803
452
|
|
|
804
|
-
##
|
|
453
|
+
## License
|
|
805
454
|
|
|
806
|
-
MIT License
|
|
455
|
+
MIT License
|
|
807
456
|
|
|
808
457
|
---
|
|
809
458
|
|