@qaiddev/quests-embed 1.3.0 → 1.4.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/dist/embed.d.ts +2 -0
- package/dist/overflow.d.ts +49 -0
- package/dist/qaid-quests.js +144 -112
- package/dist/qaid-quests.js.map +1 -1
- package/dist/qaid-quests.umd.cjs +4 -4
- package/dist/qaid-quests.umd.cjs.map +1 -1
- package/package.json +1 -1
package/dist/embed.d.ts
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeping a step readable inside whatever box the host gives us.
|
|
3
|
+
*
|
|
4
|
+
* The card body is the scroll container. Two things were missing: it never
|
|
5
|
+
* adapted its own content to the height available (option tiles have width
|
|
6
|
+
* rules only, so a short container just clipped them), and when content did
|
|
7
|
+
* overflow there was no sign of it at all — the step simply looked cut off.
|
|
8
|
+
*
|
|
9
|
+
* This module owns both. It is DOM-only and free of embed state so it can be
|
|
10
|
+
* driven directly in tests.
|
|
11
|
+
*/
|
|
12
|
+
/** Where the scroll position currently sits. */
|
|
13
|
+
export type ScrollEdge = "none" | "top" | "middle" | "bottom";
|
|
14
|
+
/**
|
|
15
|
+
* Below this many pixels of available height, a step switches to its compact
|
|
16
|
+
* layout: smaller image tiles, tighter gaps. Chosen so the common 2-3 option
|
|
17
|
+
* step fits without scrolling in a ~360px tall container.
|
|
18
|
+
*/
|
|
19
|
+
export declare const COMPACT_HEIGHT = 360;
|
|
20
|
+
/** Which edges of `el` have content beyond them. */
|
|
21
|
+
export declare function scrollEdgeOf(el: {
|
|
22
|
+
scrollTop: number;
|
|
23
|
+
scrollHeight: number;
|
|
24
|
+
clientHeight: number;
|
|
25
|
+
}): ScrollEdge;
|
|
26
|
+
/**
|
|
27
|
+
* Reflect the scroll state onto the body as `data-qaid-scroll`, which the
|
|
28
|
+
* stylesheet turns into a fade mask, and onto the cue element's hidden state.
|
|
29
|
+
*/
|
|
30
|
+
export declare function applyScrollState(body: HTMLElement, cue: HTMLElement | null): ScrollEdge;
|
|
31
|
+
/** Reflect the available height onto the card as `data-qaid-fit`. */
|
|
32
|
+
export declare function applyFitState(card: HTMLElement, availableHeight: number): "compact" | "roomy";
|
|
33
|
+
export interface OverflowWatcher {
|
|
34
|
+
/** Re-measure now — call after rendering a step. */
|
|
35
|
+
refresh(): void;
|
|
36
|
+
/** Detach every listener and observer. */
|
|
37
|
+
destroy(): void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Watch `body` for scrolling and resizing, keeping the scroll and fit state
|
|
41
|
+
* attributes current.
|
|
42
|
+
*
|
|
43
|
+
* A ResizeObserver rather than a CSS container query on height: a container
|
|
44
|
+
* query needs `container-type: size`, which requires a definite height on both
|
|
45
|
+
* axes, and this card is deliberately content-sized when the host does not
|
|
46
|
+
* constrain it. Declaring it would collapse the body to nothing in exactly the
|
|
47
|
+
* inline case the embed supports.
|
|
48
|
+
*/
|
|
49
|
+
export declare function watchOverflow(body: HTMLElement, card: HTMLElement, cue: HTMLElement | null): OverflowWatcher;
|