presently 0.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c40fe4b85c67a70eb725de902e792adfcf6adaf5d4136e1dea118078e7072dea
4
- data.tar.gz: bdb11f2d20d961f228cde6803b15ff409ab3addf9bdc84225db8bdbf57e7f215
3
+ metadata.gz: '058a674f7402cbe385bfb6db06e28f84b3bbbc0cb352512b00b1ca56f2a046ad'
4
+ data.tar.gz: 41568d05c2ade4e9a3611a750dba065c1c6217830d3d99b9703adaf621cdc9d0
5
5
  SHA512:
6
- metadata.gz: 5c046835b04d5889b429b68752face2a54c3fa6c1e6269b4e15d8a6a2fe7a311f97f61763069de50b2706b9b5d4e45d531555be094d0ba6e1c0b015df8ef7f1a
7
- data.tar.gz: 421f940ab54cf1cacda680779cc0065b9530ead96d12bdb2930c1ebf82da8289de551b31f9bd94e0aac929bfddeb306a86d08b17a99e682f6b7e7403018b9313
6
+ metadata.gz: 2b0b6ab7a6a2db77db8ddddcb72c3afa1dcf7b94a8cbc8ff70caa2bcb4c4fca354f3549ef1065eae6a80ec2a427348125eb79e65bddc7f53d15fd9f842bd1054
7
+ data.tar.gz: 01d217946531862c5e735587a4f9463bd0fcb157c3c4b6adc2fca3054fcf6181a9a38b23736abed0022da1b4bcfc80424c9791e7a4938e7de957a349310b70e4
checksums.yaml.gz.sig CHANGED
Binary file
@@ -5,5 +5,5 @@
5
5
 
6
6
  # @namespace
7
7
  module Presently
8
- VERSION = "0.8.0"
8
+ VERSION = "0.10.0"
9
9
  end
data/public/slide.js CHANGED
@@ -25,7 +25,12 @@ export class SlideBuilder {
25
25
  let revealedElement = null;
26
26
 
27
27
  this.#elements.forEach((element, index) => {
28
- element.style.viewTransitionName = `${this.#prefix}-${index + 1}`;
28
+ // Only assign a group name if the element doesn't already have an explicit one.
29
+ // Preserving explicit names allows elements to participate in morph transitions
30
+ // to other slides while still being managed by the build system.
31
+ if (!element.style.viewTransitionName || element.style.viewTransitionName === 'none') {
32
+ element.style.viewTransitionName = `${this.#prefix}-${index + 1}`;
33
+ }
29
34
 
30
35
  if (index < count) {
31
36
  element.style.visibility = 'visible';
@@ -68,7 +73,9 @@ export class SlideBuilder {
68
73
  const effect = overrides.effect !== undefined ? overrides.effect : this.#defaultEffect;
69
74
  const element = this.#elements[this.#step];
70
75
 
71
- element.style.viewTransitionName = `${this.#prefix}-${this.#step + 1}`;
76
+ if (!element.style.viewTransitionName || element.style.viewTransitionName === 'none') {
77
+ element.style.viewTransitionName = `${this.#prefix}-${this.#step + 1}`;
78
+ }
72
79
  element.style.visibility = 'visible';
73
80
  element.style.viewTransitionClass = '';
74
81
 
@@ -147,22 +154,53 @@ export class SlideElements {
147
154
  }
148
155
  }
149
156
 
150
- // Returned by Slide#after to enable relative delay chaining.
151
- // Each .after(delay, callback) fires that many milliseconds after the previous step.
152
- class SlideChain {
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 {
153
163
  #slide;
154
164
  #elapsed;
155
165
 
156
- constructor(slide, elapsed) {
166
+ constructor(slide, elapsed = 0) {
157
167
  this.#slide = slide;
158
168
  this.#elapsed = elapsed;
159
169
  }
160
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]
161
192
  after(delay, callback) {
162
193
  this.#elapsed += delay;
163
194
  this.#slide.setTimeout(callback, this.#elapsed);
164
195
  return this;
165
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
+ }
166
204
  }
167
205
 
168
206
  // The scripting context passed to each slide's javascript block.
@@ -195,15 +233,30 @@ export class Slide {
195
233
  return timeoutId;
196
234
  }
197
235
 
198
- // Schedule a callback after a delay, returning a chainable object so
236
+ // Schedule a callback after a delay, returning a SlideContext so
199
237
  // subsequent .after(delay) calls are relative to the previous step.
200
238
  // All timeouts are tracked and cancelled automatically on slide change.
201
- // @parameter delay [Number] Delay in milliseconds from now (or previous step).
239
+ // @parameter delay [Number] Delay in milliseconds from now.
202
240
  // @parameter callback [Function] The function to call after the delay.
203
- // @returns [SlideChain]
241
+ // @returns [SlideContext]
204
242
  after(delay, callback) {
205
243
  this.setTimeout(callback, delay);
206
- return new SlideChain(this, delay);
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();
207
260
  }
208
261
 
209
262
  // Cancel all pending timeouts registered by this slide's script.
data/readme.md CHANGED
@@ -29,6 +29,15 @@ 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
+
37
+ ### v0.9.0
38
+
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.
40
+
32
41
  ### v0.8.0
33
42
 
34
43
  - Add optional `translation` section to the `default` template.
data/releases.md CHANGED
@@ -1,5 +1,14 @@
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
+
8
+ ## v0.9.0
9
+
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.
11
+
3
12
  ## v0.8.0
4
13
 
5
14
  - Add optional `translation` section to the `default` template.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: presently
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
@@ -1 +1,2 @@
1
- ��V�y�ӆ1$�Kw��@I\��J�����\�o�/? ���ȸ�4��h-�v��֟]
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 �