sketchmark 1.1.2 → 1.1.3
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.
Potentially problematic release.
This version of sketchmark might be problematic. Click here for more details.
- package/dist/animation/index.d.ts +5 -0
- package/dist/animation/index.d.ts.map +1 -1
- package/dist/index.cjs +26 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -9
- package/dist/index.js.map +1 -1
- package/dist/sketchmark.iife.js +26 -9
- package/package.json +71 -72
package/dist/index.js
CHANGED
|
@@ -9246,11 +9246,13 @@ class AnimationController {
|
|
|
9246
9246
|
this._config = _config;
|
|
9247
9247
|
this._step = -1;
|
|
9248
9248
|
this._pendingStepTimers = new Set();
|
|
9249
|
+
this._pendingNarrationTimers = new Set();
|
|
9249
9250
|
this._transforms = new Map();
|
|
9250
9251
|
this._listeners = [];
|
|
9251
9252
|
// ── Narration caption ──
|
|
9252
9253
|
this._captionEl = null;
|
|
9253
9254
|
this._captionTextEl = null;
|
|
9255
|
+
this._narrationRunId = 0;
|
|
9254
9256
|
// ── Annotations ──
|
|
9255
9257
|
this._annotationLayer = null;
|
|
9256
9258
|
this._annotations = [];
|
|
@@ -9513,20 +9515,30 @@ class AnimationController {
|
|
|
9513
9515
|
}
|
|
9514
9516
|
this.emit("step-change");
|
|
9515
9517
|
}
|
|
9518
|
+
_clearTimerBucket(bucket) {
|
|
9519
|
+
bucket.forEach((id) => window.clearTimeout(id));
|
|
9520
|
+
bucket.clear();
|
|
9521
|
+
}
|
|
9516
9522
|
_clearPendingStepTimers() {
|
|
9517
|
-
this.
|
|
9518
|
-
this._pendingStepTimers.clear();
|
|
9523
|
+
this._clearTimerBucket(this._pendingStepTimers);
|
|
9519
9524
|
}
|
|
9520
|
-
|
|
9525
|
+
_cancelNarrationTyping() {
|
|
9526
|
+
this._narrationRunId += 1;
|
|
9527
|
+
this._clearTimerBucket(this._pendingNarrationTimers);
|
|
9528
|
+
}
|
|
9529
|
+
_scheduleTimer(fn, delayMs, bucket = this._pendingStepTimers) {
|
|
9521
9530
|
if (delayMs <= 0) {
|
|
9522
9531
|
fn();
|
|
9523
9532
|
return;
|
|
9524
9533
|
}
|
|
9525
9534
|
const id = window.setTimeout(() => {
|
|
9526
|
-
|
|
9535
|
+
bucket.delete(id);
|
|
9527
9536
|
fn();
|
|
9528
9537
|
}, delayMs);
|
|
9529
|
-
|
|
9538
|
+
bucket.add(id);
|
|
9539
|
+
}
|
|
9540
|
+
_scheduleStep(fn, delayMs) {
|
|
9541
|
+
this._scheduleTimer(fn, delayMs, this._pendingStepTimers);
|
|
9530
9542
|
}
|
|
9531
9543
|
_stepWaitMs(step, fallbackMs) {
|
|
9532
9544
|
const delay = Math.max(0, step.delay ?? 0);
|
|
@@ -9570,6 +9582,7 @@ class AnimationController {
|
|
|
9570
9582
|
}
|
|
9571
9583
|
_clearAll() {
|
|
9572
9584
|
this._clearPendingStepTimers();
|
|
9585
|
+
this._cancelNarrationTyping();
|
|
9573
9586
|
this._cancelSpeech();
|
|
9574
9587
|
this._transforms.clear();
|
|
9575
9588
|
// Nodes
|
|
@@ -10124,6 +10137,7 @@ class AnimationController {
|
|
|
10124
10137
|
_doNarrate(text, silent) {
|
|
10125
10138
|
if (!this._captionEl || !this._captionTextEl)
|
|
10126
10139
|
return;
|
|
10140
|
+
this._cancelNarrationTyping();
|
|
10127
10141
|
this._captionEl.style.opacity = "1";
|
|
10128
10142
|
if (silent || !text) {
|
|
10129
10143
|
this._captionTextEl.textContent = text;
|
|
@@ -10134,12 +10148,16 @@ class AnimationController {
|
|
|
10134
10148
|
this._speak(text);
|
|
10135
10149
|
// Typing effect
|
|
10136
10150
|
this._captionTextEl.textContent = "";
|
|
10151
|
+
const narrationRunId = this._narrationRunId;
|
|
10137
10152
|
let charIdx = 0;
|
|
10138
10153
|
const typeNext = () => {
|
|
10154
|
+
if (this._narrationRunId !== narrationRunId || !this._captionTextEl)
|
|
10155
|
+
return;
|
|
10139
10156
|
if (charIdx < text.length) {
|
|
10140
10157
|
this._captionTextEl.textContent += text[charIdx++];
|
|
10141
|
-
|
|
10142
|
-
|
|
10158
|
+
if (charIdx < text.length) {
|
|
10159
|
+
this._scheduleTimer(typeNext, ANIMATION.narrationTypeMs, this._pendingNarrationTimers);
|
|
10160
|
+
}
|
|
10143
10161
|
}
|
|
10144
10162
|
};
|
|
10145
10163
|
typeNext();
|
|
@@ -10249,12 +10267,11 @@ class AnimationController {
|
|
|
10249
10267
|
requestAnimationFrame(animate);
|
|
10250
10268
|
}
|
|
10251
10269
|
// After guide finishes: reveal rough.js element, remove guide
|
|
10252
|
-
|
|
10270
|
+
this._scheduleTimer(() => {
|
|
10253
10271
|
roughEl.style.transition = `opacity 120ms ease`;
|
|
10254
10272
|
roughEl.style.opacity = "1";
|
|
10255
10273
|
guide.remove();
|
|
10256
10274
|
}, dur + 30);
|
|
10257
|
-
this._pendingStepTimers.add(id);
|
|
10258
10275
|
}));
|
|
10259
10276
|
}
|
|
10260
10277
|
_doAnnotationCircle(target, silent) {
|