zumly 0.92.6 → 0.97.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/README.md +55 -18
- package/dist/zumly.cjs +2 -2
- package/dist/zumly.css +15 -0
- package/dist/zumly.js +2 -2
- package/dist/zumly.min.css +1 -1
- package/dist/zumly.mjs +2 -2
- package/package.json +9 -5
- package/src/drivers/anime-transition.js +5 -5
- package/src/drivers/driver-helpers.js +8 -3
- package/src/drivers/motion-transition.js +5 -5
- package/src/drivers/transform-matrix.js +34 -0
- package/src/view-lifecycle.js +70 -0
- package/src/view-visibility.js +43 -0
- package/types/zumly.d.ts +13 -10
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized `content-visibility` handling for view layers during zoom prep / teardown.
|
|
3
|
+
* Single source of truth — .z-view.hide only handles opacity; this module controls content-visibility.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Shared across the bundled engine and separately imported driver helpers.
|
|
7
|
+
const visibilityKey = Symbol.for('zumly.viewVisibility')
|
|
8
|
+
|
|
9
|
+
function rememberVisibility (element) {
|
|
10
|
+
if (element[visibilityKey]) return
|
|
11
|
+
Object.defineProperty(element, visibilityKey, {
|
|
12
|
+
configurable: true,
|
|
13
|
+
value: {
|
|
14
|
+
value: element.style.getPropertyValue('content-visibility'),
|
|
15
|
+
priority: element.style.getPropertyPriority('content-visibility')
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** @param {HTMLElement | null | undefined} element */
|
|
21
|
+
export function hideViewContent (element) {
|
|
22
|
+
if (!element) return
|
|
23
|
+
rememberVisibility(element)
|
|
24
|
+
element.style.contentVisibility = 'hidden'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @param {HTMLElement | null | undefined} element
|
|
29
|
+
*/
|
|
30
|
+
export function showViewContent (element) {
|
|
31
|
+
if (!element) return
|
|
32
|
+
rememberVisibility(element)
|
|
33
|
+
element.style.contentVisibility = 'visible'
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Release the temporary transition override, preserving the host's CSS policy. */
|
|
37
|
+
export function restoreViewContent (element) {
|
|
38
|
+
const original = element?.[visibilityKey]
|
|
39
|
+
if (!original) return
|
|
40
|
+
if (original.value) element.style.setProperty('content-visibility', original.value, original.priority)
|
|
41
|
+
else element.style.removeProperty('content-visibility')
|
|
42
|
+
delete element[visibilityKey]
|
|
43
|
+
}
|
package/types/zumly.d.ts
CHANGED
|
@@ -12,7 +12,9 @@ export interface ViewContext {
|
|
|
12
12
|
/** The componentContext from Zumly constructor options. */
|
|
13
13
|
context: Map<string, unknown> | Record<string, unknown>
|
|
14
14
|
/** Data attributes from the trigger element (e.g. data-id="42" → props.id). */
|
|
15
|
-
props: Record<string,
|
|
15
|
+
props: Record<string, unknown>
|
|
16
|
+
/** Register component unmount or resource cleanup, run once when this view is discarded. */
|
|
17
|
+
onCleanup(callback: () => void | Promise<void>): void
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
/** A function that receives context and returns a view. */
|
|
@@ -53,7 +55,7 @@ export interface TransitionSpec {
|
|
|
53
55
|
slideDeltaX?: number
|
|
54
56
|
slideDeltaY?: number
|
|
55
57
|
/** When true, driver should not remove the outgoing view from DOM (lateral keepAlive). */
|
|
56
|
-
keepAlive?: boolean
|
|
58
|
+
keepAlive?: boolean | 'visible'
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
/** Custom driver function signature. */
|
|
@@ -136,7 +138,7 @@ export interface DepthNavOptions {
|
|
|
136
138
|
export interface InputsOptions {
|
|
137
139
|
/** Enable wheel zoom-out. Default: true. */
|
|
138
140
|
wheel?: boolean
|
|
139
|
-
/** Enable keyboard navigation (arrow keys). Default: true. */
|
|
141
|
+
/** Enable keyboard navigation (Enter/Space on triggers, arrow keys for back). Default: true. */
|
|
140
142
|
keyboard?: boolean
|
|
141
143
|
/** Enable click/mouseup navigation. Default: true. */
|
|
142
144
|
click?: boolean
|
|
@@ -193,7 +195,7 @@ export interface ZumlyOptions {
|
|
|
193
195
|
/** Depth navigation UI. true = default (back button, bottom-left), false = disabled. */
|
|
194
196
|
depthNav?: boolean | DepthNavOptions
|
|
195
197
|
/** Input types to enable/disable. All enabled by default. */
|
|
196
|
-
inputs?: InputsOptions
|
|
198
|
+
inputs?: boolean | InputsOptions
|
|
197
199
|
/** Enable deferred rendering (view content inserted after zoom animation). */
|
|
198
200
|
deferred?: boolean
|
|
199
201
|
}
|
|
@@ -278,27 +280,28 @@ export class Zumly {
|
|
|
278
280
|
getCurrentViewName(): string | null
|
|
279
281
|
|
|
280
282
|
/**
|
|
281
|
-
* Navigate to a view by name.
|
|
283
|
+
* Navigate to a view by name. Resolves after the transition completes.
|
|
284
|
+
* Calls made while another navigation is loading/animating are ignored.
|
|
282
285
|
*/
|
|
283
286
|
goTo(viewName: string, options?: GoToOptions): Promise<void>
|
|
284
287
|
|
|
285
288
|
/**
|
|
286
289
|
* Programmatic zoom to a named view (depth navigation).
|
|
287
|
-
* Uses a centered synthetic trigger for the transition.
|
|
290
|
+
* Uses a centered synthetic trigger for the transition. Resolves after animation.
|
|
288
291
|
*/
|
|
289
292
|
zoomTo(viewName: string, options?: ZoomToOptions): Promise<void>
|
|
290
293
|
|
|
291
294
|
/** Zoom into the view indicated by a trigger element with data-to="viewName". */
|
|
292
295
|
zoomIn(el: HTMLElement): Promise<void>
|
|
293
296
|
|
|
294
|
-
/** Zoom out one level.
|
|
295
|
-
zoomOut(): void
|
|
297
|
+
/** Zoom out one level. Resolves after animation; no-op at root. */
|
|
298
|
+
zoomOut(): Promise<void>
|
|
296
299
|
|
|
297
300
|
/**
|
|
298
301
|
* Navigate back. Pops lateral history first, then zooms out.
|
|
299
|
-
*
|
|
302
|
+
* Resolves after the navigation completes.
|
|
300
303
|
*/
|
|
301
|
-
back(): Promise<void>
|
|
304
|
+
back(): Promise<void>
|
|
302
305
|
}
|
|
303
306
|
|
|
304
307
|
export default Zumly
|