presently 0.9.0 → 0.10.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/presently/version.rb +1 -1
- data/public/slide.js +54 -8
- data/readme.md +5 -0
- data/releases.md +5 -0
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '058a674f7402cbe385bfb6db06e28f84b3bbbc0cb352512b00b1ca56f2a046ad'
|
|
4
|
+
data.tar.gz: 41568d05c2ade4e9a3611a750dba065c1c6217830d3d99b9703adaf621cdc9d0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2b0b6ab7a6a2db77db8ddddcb72c3afa1dcf7b94a8cbc8ff70caa2bcb4c4fca354f3549ef1065eae6a80ec2a427348125eb79e65bddc7f53d15fd9f842bd1054
|
|
7
|
+
data.tar.gz: 01d217946531862c5e735587a4f9463bd0fcb157c3c4b6adc2fca3054fcf6181a9a38b23736abed0022da1b4bcfc80424c9791e7a4938e7de957a349310b70e4
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/lib/presently/version.rb
CHANGED
data/public/slide.js
CHANGED
|
@@ -154,22 +154,53 @@ export class SlideElements {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
//
|
|
158
|
-
//
|
|
159
|
-
|
|
157
|
+
// Scoped scripting context used both for chaining after() calls and as the
|
|
158
|
+
// argument passed to slide.loop() callbacks. Accumulates elapsed time across
|
|
159
|
+
// after() calls so each delay is relative to the previous step. Delegates
|
|
160
|
+
// find() and setTimeout() to the parent Slide so element queries are scoped
|
|
161
|
+
// correctly and all timeouts are cancelled automatically on slide change.
|
|
162
|
+
export class SlideContext {
|
|
160
163
|
#slide;
|
|
161
164
|
#elapsed;
|
|
162
165
|
|
|
163
|
-
constructor(slide, elapsed) {
|
|
166
|
+
constructor(slide, elapsed = 0) {
|
|
164
167
|
this.#slide = slide;
|
|
165
168
|
this.#elapsed = elapsed;
|
|
166
169
|
}
|
|
167
170
|
|
|
171
|
+
// Find elements within the slide matching the given CSS selector.
|
|
172
|
+
// Delegates to the parent Slide.
|
|
173
|
+
// @parameter selector [String] A CSS selector scoped to the slide body.
|
|
174
|
+
// @returns [SlideElements]
|
|
175
|
+
find(selector) {
|
|
176
|
+
return this.#slide.find(selector);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Tracked setTimeout — delegates to the parent Slide so timeouts are
|
|
180
|
+
// cancelled automatically when the slide changes.
|
|
181
|
+
// @parameter callback [Function] The function to call after the delay.
|
|
182
|
+
// @parameter delay [Number] Delay in milliseconds.
|
|
183
|
+
// @returns [Number] The timeout ID.
|
|
184
|
+
setTimeout(callback, delay) {
|
|
185
|
+
return this.#slide.setTimeout(callback, delay);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// Schedule a callback relative to the previous step, accumulating elapsed time.
|
|
189
|
+
// @parameter delay [Number] Delay in milliseconds after the previous step.
|
|
190
|
+
// @parameter callback [Function] The function to call.
|
|
191
|
+
// @returns [SlideContext]
|
|
168
192
|
after(delay, callback) {
|
|
169
193
|
this.#elapsed += delay;
|
|
170
194
|
this.#slide.setTimeout(callback, this.#elapsed);
|
|
171
195
|
return this;
|
|
172
196
|
}
|
|
197
|
+
|
|
198
|
+
// Total time accumulated across all after() calls.
|
|
199
|
+
// Used by slide.loop() to know when to schedule the next iteration.
|
|
200
|
+
// @returns [Number] Elapsed time in milliseconds.
|
|
201
|
+
get elapsed() {
|
|
202
|
+
return this.#elapsed;
|
|
203
|
+
}
|
|
173
204
|
}
|
|
174
205
|
|
|
175
206
|
// The scripting context passed to each slide's javascript block.
|
|
@@ -202,15 +233,30 @@ export class Slide {
|
|
|
202
233
|
return timeoutId;
|
|
203
234
|
}
|
|
204
235
|
|
|
205
|
-
// Schedule a callback after a delay, returning a
|
|
236
|
+
// Schedule a callback after a delay, returning a SlideContext so
|
|
206
237
|
// subsequent .after(delay) calls are relative to the previous step.
|
|
207
238
|
// All timeouts are tracked and cancelled automatically on slide change.
|
|
208
|
-
// @parameter delay [Number] Delay in milliseconds from now
|
|
239
|
+
// @parameter delay [Number] Delay in milliseconds from now.
|
|
209
240
|
// @parameter callback [Function] The function to call after the delay.
|
|
210
|
-
// @returns [
|
|
241
|
+
// @returns [SlideContext]
|
|
211
242
|
after(delay, callback) {
|
|
212
243
|
this.setTimeout(callback, delay);
|
|
213
|
-
return new
|
|
244
|
+
return new SlideContext(this, delay);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Run a callback in a loop, repeating indefinitely until the slide changes.
|
|
248
|
+
// The callback receives a SlideContext so it can use after() to schedule
|
|
249
|
+
// steps within each iteration. The loop waits for all steps to complete
|
|
250
|
+
// (ctx.elapsed) plus an optional extra delay before starting the next iteration.
|
|
251
|
+
// @parameter callback [Function] Receives a fresh SlideContext as `context` each iteration.
|
|
252
|
+
// @parameter delay [Number] Extra pause in milliseconds after the last step before restarting.
|
|
253
|
+
loop(callback, { delay = 0 } = {}) {
|
|
254
|
+
const iterate = () => {
|
|
255
|
+
const context = new SlideContext(this);
|
|
256
|
+
callback(context);
|
|
257
|
+
this.setTimeout(iterate, context.elapsed + delay);
|
|
258
|
+
};
|
|
259
|
+
iterate();
|
|
214
260
|
}
|
|
215
261
|
|
|
216
262
|
// Cancel all pending timeouts registered by this slide's script.
|
data/readme.md
CHANGED
|
@@ -29,6 +29,11 @@ Please see the [project documentation](https://socketry.github.io/presently/) fo
|
|
|
29
29
|
|
|
30
30
|
Please see the [project releases](https://socketry.github.io/presently/releases/index) for all releases.
|
|
31
31
|
|
|
32
|
+
### v0.10.0
|
|
33
|
+
|
|
34
|
+
- Replace internal `SlideChain` with an exported `SlideContext` class. `SlideContext` accumulates elapsed time across `after()` calls exactly as `SlideChain` did, but also exposes `find()`, `setTimeout()`, and a `get elapsed()` getter. `Slide#after()` now returns a `SlideContext` — existing slide scripts are unaffected.
|
|
35
|
+
- Add `Slide#loop(callback, {delay})` — runs a callback in a repeating loop until the slide changes. The callback receives a fresh `SlideContext` each iteration so it can schedule steps with `after()`. The loop waits for all steps to complete (`context.elapsed`) plus an optional extra `delay` before starting the next iteration. All timeouts flow through the slide's existing tracked `setTimeout`, so they are cancelled automatically on slide change.
|
|
36
|
+
|
|
32
37
|
### v0.9.0
|
|
33
38
|
|
|
34
39
|
- `SlideBuilder#show` and `SlideBuilder#next` no longer overwrite `view-transition-name` on elements that already have one set. This allows elements with explicit names (for morph transitions to other slides) to coexist with the build system — they still get `visibility` and `viewTransitionClass` managed, but keep their own name.
|
data/releases.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Releases
|
|
2
2
|
|
|
3
|
+
## v0.10.0
|
|
4
|
+
|
|
5
|
+
- Replace internal `SlideChain` with an exported `SlideContext` class. `SlideContext` accumulates elapsed time across `after()` calls exactly as `SlideChain` did, but also exposes `find()`, `setTimeout()`, and a `get elapsed()` getter. `Slide#after()` now returns a `SlideContext` — existing slide scripts are unaffected.
|
|
6
|
+
- Add `Slide#loop(callback, {delay})` — runs a callback in a repeating loop until the slide changes. The callback receives a fresh `SlideContext` each iteration so it can schedule steps with `after()`. The loop waits for all steps to complete (`context.elapsed`) plus an optional extra `delay` before starting the next iteration. All timeouts flow through the slide's existing tracked `setTimeout`, so they are cancelled automatically on slide change.
|
|
7
|
+
|
|
3
8
|
## v0.9.0
|
|
4
9
|
|
|
5
10
|
- `SlideBuilder#show` and `SlideBuilder#next` no longer overwrite `view-transition-name` on elements that already have one set. This allows elements with explicit names (for morph transitions to other slides) to coexist with the build system — they still get `visibility` and `viewTransitionClass` managed, but keep their own name.
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
6Iq�r=+�q� ����:\��v��~�Z2W{�G�
|
|
2
|
+
��>Y��W����i��n��|�ᣕmV��%��¡���4�ޖY���i���M�K�oμ�_@~��S�lo�l���)�V>�uv�Rt� ��\ˉ3�o�P%0Ѐ�`�߁�g�O齎O�Pi��P ��δE��H����-�#�(���pqnlK�YSK��B��Mϵ}sVa�Ŝ��Xh�b ��RΘ�n_Y�a)뮃���/kȫ���5h)d��? Qmx�R���f@���@d�gL�j!����lM��6 aX��>�L���@�q�4�')��{m���f�7<f�[ �bX}���[���n��b���S�^�^ed�
|