ts-toolkit icon indicating copy to clipboard operation
ts-toolkit copied to clipboard

Move commandsto JumpToLocation

Open chocolatkey opened this issue 3 years ago • 0 comments

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:

  1. The app calls a go_x command in the JumpToLocation module.
  2. The command computes a target DOMRect, then requests the Snapper to snap_to the target rect (with a command event, or direct function call).
  3. The Snapper will 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.).
  4. The Snapper will 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

chocolatkey avatar Nov 01 '22 01:11 chocolatkey