ts-toolkit
ts-toolkit copied to clipboard
Move commandsto JumpToLocation
Some of the go commands should be in the JumpToLocation module, such as go_text and go_id. Snapper's job is only to scroll+snap the content when requested.
This implies that some modules like JumpToLocation might depend on APIs provided by the Snapper. Maybe we can use commands/events for this instead of direct access.
It could flow like this:
- The app calls a
go_xcommand in theJumpToLocationmodule. - The command computes a target
DOMRect, then requests theSnappertosnap_tothe target rect (with a command event, or direct function call). - The
Snapperwill resolve the target rect to an actual offset, depending on the technique used for the positioning (CSS translation, native scroll, etc.) and the layout nature (paginated, scrolled, RTL, etc.). - The
Snapperwill move the viewport to the target offset, with an animation if requested.
Originally posted by @mickael-menu in https://github.com/readium/ts-toolkit/pull/12#discussion_r948046203