fix: restore zoom level persistence on page load

Zoom level persistence was broken because hyperscript was setting the
container's value instead of the slider's value on page load.

Changes:
- Fix zoom-control.html line 10: set #zoom-slider's value (not 'my value')
- Add comprehensive zoom persistence test (10-zoom-persistence.test.mjs)
- Update cv-functions.js documentation to clarify hyperscript interop
- Add zoom control feature to README

Test results: 5/5 tests pass
- Zoom saves to localStorage when changed 
- Zoom restores correctly on page reload 
- Reset to 100% works and persists 

Architecture note:
- Hyperscript 'call' within _="" attributes requires global JS scope
- JavaScript wrappers bridge window exposure to hyperscript evaluate()
- Pattern: window.fn() → _hyperscript.evaluate('hyperscriptFn()')
This commit is contained in:
juanatsap
2025-11-17 16:56:01 +00:00
parent 491aa66920
commit 35a836adf3
4 changed files with 233 additions and 6 deletions
+7 -5
View File
@@ -7,10 +7,12 @@
* These are thin JavaScript wrappers that delegate to Hyperscript functions.
*
* Why wrappers are needed:
* - Hyperscript `call` command requires functions in global JavaScript scope
* - Hyperscript `def` functions are NOT automatically exposed to window
* - Templates use `_="on mouseenter call syncPdfHover(true)"`
* - This syntax expects a JavaScript function, not a hyperscript def
* - Hyperscript's `call` command within `_=""` attributes requires functions in global JS scope
* - While hyperscript docs state "global hyperscript functions can be called from JavaScript",
* the reverse (JS calling hyperscript via `call` in attributes) requires window exposure
* - Templates use `_="on mouseenter call syncPdfHover(true)"` syntax
* - Hyperscript `def` functions are accessible via _hyperscript.evaluate() but not window.functionName
* - These wrappers bridge the gap by exposing to window and delegating to hyperscript
*
* Implementation in Hyperscript:
* - toggleCVLength() → static/hyperscript/toggles._hs
@@ -20,7 +22,7 @@
* - syncPrintHover() → static/hyperscript/hover-sync._hs
* - highlightZoomControl() → static/hyperscript/hover-sync._hs
*
* These wrappers call the hyperscript implementations via _hyperscript API.
* Pattern: window.functionName() → _hyperscript.evaluate('hyperscriptFunction()')
*/
/**