@diabolic/pointy 1.0.3 → 1.1.0
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 +61 -3
- package/dist/pointy.esm.js +34 -10
- package/dist/pointy.js +34 -10
- package/dist/pointy.min.js +1 -1
- package/dist/pointy.min.js.map +1 -1
- package/package.json +1 -1
- package/src/pointy.js +33 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diabolic/pointy",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A lightweight, dependency-free JavaScript library for creating animated tooltips with a pointing cursor. Perfect for product tours, onboarding flows, and feature highlights.",
|
|
6
6
|
"main": "dist/pointy.js",
|
package/src/pointy.js
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
* - steps {Array<{target, content, direction?, duration?}>} - Tour steps
|
|
21
21
|
* - target {string|HTMLElement} - Initial target element
|
|
22
22
|
* - content {string|string[]} - Initial content/messages (single-step use)
|
|
23
|
+
* - zIndex {number} - CSS z-index for the container (default: 9999)
|
|
23
24
|
* - offsetX {number} - Horizontal offset from target (default: 20)
|
|
24
25
|
* - offsetY {number} - Vertical offset from target (default: 16)
|
|
25
26
|
* - trackingFps {number} - Position update FPS, 0 = unlimited (default: 60)
|
|
@@ -74,8 +75,8 @@
|
|
|
74
75
|
* - introAnimationEnd: Initial fade-in animation completed
|
|
75
76
|
*
|
|
76
77
|
* Content:
|
|
77
|
-
* - messagesSet: Messages array replaced via setMessages()
|
|
78
|
-
* -
|
|
78
|
+
* - messagesSet: Messages array replaced via setMessages() or setMessage()
|
|
79
|
+
* - currentMessageUpdate: Current message updated via setCurrentMessage()
|
|
79
80
|
* - messageChange: Message changed (navigation or auto-cycle)
|
|
80
81
|
*
|
|
81
82
|
* Message Cycle:
|
|
@@ -127,7 +128,7 @@
|
|
|
127
128
|
* Core: show(), hide(), destroy()
|
|
128
129
|
* Navigation: next(), prev(), goToStep(index), reset(), restart()
|
|
129
130
|
* Custom Target: pointTo(target, content?, direction?)
|
|
130
|
-
* Content: setMessages(content), setMessage(msg), nextMessage(), prevMessage(), goToMessage(index)
|
|
131
|
+
* Content: setMessages(content), setMessage(msg), setCurrentMessage(msg), nextMessage(), prevMessage(), goToMessage(index)
|
|
131
132
|
* Message Cycle: startMessageCycle(interval?), stopMessageCycle(), pauseMessageCycle(), resumeMessageCycle()
|
|
132
133
|
* Autoplay: startAutoplay(), stopAutoplay(), pauseAutoplay(), resumeAutoplay()
|
|
133
134
|
* Animation: animateToInitialPosition()
|
|
@@ -136,8 +137,8 @@
|
|
|
136
137
|
*
|
|
137
138
|
* Setters (all emit change events):
|
|
138
139
|
* setEasing(), setAnimationDuration(), setIntroFadeDuration(), setBubbleFadeDuration(),
|
|
139
|
-
* setMessageInterval(), setMessageTransitionDuration(), setOffset(),
|
|
140
|
-
* setFloatingAnimation(), setInitialPosition(), setInitialPositionOffset(),
|
|
140
|
+
* setMessageInterval(), setMessageTransitionDuration(), setOffset(), setZIndex(),
|
|
141
|
+
* setResetOnComplete(), setFloatingAnimation(), setInitialPosition(), setInitialPositionOffset(),
|
|
141
142
|
* setAutoplay(), setAutoplayWaitForMessages()
|
|
142
143
|
*
|
|
143
144
|
* Static Helpers:
|
|
@@ -243,7 +244,6 @@ class Pointy {
|
|
|
243
244
|
|
|
244
245
|
.${cn.container} {
|
|
245
246
|
position: absolute;
|
|
246
|
-
z-index: 9999;
|
|
247
247
|
font-family: 'Circular', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
248
248
|
--${vp}-duration: 1000ms;
|
|
249
249
|
--${vp}-easing: cubic-bezier(0, 0.55, 0.45, 1);
|
|
@@ -435,6 +435,7 @@ class Pointy {
|
|
|
435
435
|
Pointy.injectStyles(this.classNames, this.cssVarPrefix);
|
|
436
436
|
|
|
437
437
|
this.steps = options.steps || [];
|
|
438
|
+
this.zIndex = options.zIndex !== undefined ? options.zIndex : 9999; // CSS z-index
|
|
438
439
|
this.offsetX = options.offsetX !== undefined ? options.offsetX : 20;
|
|
439
440
|
this.offsetY = options.offsetY !== undefined ? options.offsetY : 16;
|
|
440
441
|
this.tracking = options.tracking !== undefined ? options.tracking : true; // Enable/disable position tracking
|
|
@@ -487,6 +488,7 @@ class Pointy {
|
|
|
487
488
|
// Create DOM elements - pointer is the anchor, bubble positioned relative to it
|
|
488
489
|
this.container = document.createElement('div');
|
|
489
490
|
this.container.className = `${this.classNames.container} ${this.classNames.hidden}`;
|
|
491
|
+
this.container.style.zIndex = this.zIndex;
|
|
490
492
|
this.container.style.setProperty(`--${this.cssVarPrefix}-duration`, `${this.animationDuration}ms`);
|
|
491
493
|
this.container.style.setProperty(`--${this.cssVarPrefix}-easing`, this._resolveEasing(this.easing));
|
|
492
494
|
this.container.style.setProperty(`--${this.cssVarPrefix}-bubble-fade`, `${this.bubbleFadeDuration}ms`);
|
|
@@ -1306,11 +1308,11 @@ class Pointy {
|
|
|
1306
1308
|
}
|
|
1307
1309
|
|
|
1308
1310
|
/**
|
|
1309
|
-
*
|
|
1311
|
+
* Update the message at current index only (does not replace all messages)
|
|
1310
1312
|
* @param {string} message - New message content
|
|
1311
1313
|
* @param {boolean} animate - Whether to animate the change (default: true)
|
|
1312
1314
|
*/
|
|
1313
|
-
|
|
1315
|
+
setCurrentMessage(message, animate = true) {
|
|
1314
1316
|
const oldMessage = this.currentMessages[this.currentMessageIndex];
|
|
1315
1317
|
this.currentMessages[this.currentMessageIndex] = message;
|
|
1316
1318
|
|
|
@@ -1321,7 +1323,7 @@ class Pointy {
|
|
|
1321
1323
|
this.updatePosition();
|
|
1322
1324
|
}
|
|
1323
1325
|
|
|
1324
|
-
this._emit('
|
|
1326
|
+
this._emit('currentMessageUpdate', {
|
|
1325
1327
|
index: this.currentMessageIndex,
|
|
1326
1328
|
message: message,
|
|
1327
1329
|
oldMessage: oldMessage,
|
|
@@ -1330,6 +1332,15 @@ class Pointy {
|
|
|
1330
1332
|
});
|
|
1331
1333
|
}
|
|
1332
1334
|
|
|
1335
|
+
/**
|
|
1336
|
+
* Set a single message (replaces all messages with one)
|
|
1337
|
+
* @param {string} message - Message content
|
|
1338
|
+
* @param {boolean} animate - Whether to animate the change (default: true)
|
|
1339
|
+
*/
|
|
1340
|
+
setMessage(message, animate = true) {
|
|
1341
|
+
this.setMessages(message, animate);
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1333
1344
|
/**
|
|
1334
1345
|
* Set messages programmatically (replaces current messages)
|
|
1335
1346
|
* @param {string|string[]} content - Single message or array of messages
|
|
@@ -1392,6 +1403,19 @@ class Pointy {
|
|
|
1392
1403
|
this._emit('targetChange', { from: oldTarget, to: this.targetElement });
|
|
1393
1404
|
}
|
|
1394
1405
|
|
|
1406
|
+
/**
|
|
1407
|
+
* Set the z-index of the container
|
|
1408
|
+
* @param {number} zIndex - CSS z-index value
|
|
1409
|
+
*/
|
|
1410
|
+
setZIndex(zIndex) {
|
|
1411
|
+
const oldValue = this.zIndex;
|
|
1412
|
+
if (oldValue === zIndex) return;
|
|
1413
|
+
|
|
1414
|
+
this.zIndex = zIndex;
|
|
1415
|
+
this.container.style.zIndex = zIndex;
|
|
1416
|
+
this._emit('zIndexChange', { from: oldValue, to: zIndex });
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1395
1419
|
setOffset(offsetX, offsetY) {
|
|
1396
1420
|
const oldOffsetX = this.offsetX;
|
|
1397
1421
|
const oldOffsetY = this.offsetY;
|