Skip to content

Commit 75c5a8f

Browse files
Expose Slide element.
1 parent d27b06b commit 75c5a8f

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

public/slide.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ export class SlideContext {
168168
this.#elapsed = elapsed;
169169
}
170170

171+
// The slide body element.
172+
// Delegates to the parent Slide.
173+
// @returns [HTMLElement]
174+
get element() {
175+
return this.#slide.element;
176+
}
177+
171178
// Find elements within the slide matching the given CSS selector.
172179
// Delegates to the parent Slide.
173180
// @parameter selector [String] A CSS selector scoped to the slide body.
@@ -206,19 +213,25 @@ export class SlideContext {
206213
// The scripting context passed to each slide's javascript block.
207214
// Scopes element queries to the slide body.
208215
export class Slide {
209-
#container;
216+
#element;
210217
#timeouts = [];
211218

212-
constructor(container) {
213-
this.#container = container;
219+
constructor(element) {
220+
this.#element = element;
221+
}
222+
223+
// The slide body element.
224+
// @returns [HTMLElement]
225+
get element() {
226+
return this.#element;
214227
}
215228

216229
// Find elements within this slide matching the given CSS selector.
217230
// Use comma-separated selectors to combine multiple element types, e.g. "h2, li".
218231
// @parameter selector [String] A CSS selector scoped to the slide body.
219232
// @returns [SlideElements]
220233
find(selector) {
221-
const elements = Array.from(this.#container.querySelectorAll(selector));
234+
const elements = Array.from(this.#element.querySelectorAll(selector));
222235
return new SlideElements(this, elements);
223236
}
224237

releases.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Releases
22

3+
## Unreleased
4+
5+
- Add `Slide#element` and `SlideContext#element` getters — expose the slide body DOM element directly for cases where `find()` is not sufficient, such as measuring dimensions, attaching event listeners, or integrating third-party libraries.
6+
37
## v0.10.0
48

59
- 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.

0 commit comments

Comments
 (0)