A multi-group view navigation system. Register named frames as views inside independent groups, then navigate between them with animated transitions — forward, back, or toggling.
RouterService manages any number of independent navigation groups (e.g., MainMenu, HUD, Settings). Each group tracks its current view and transitions between frames using positional tweens plus optional CanvasGroup fade. Pressing navigate on the currently-open view closes it (toggle behavior).
Quick start — two views in one group
Each view can have its own enter/exit direction. The default is 'up' — the frame slides in from below and exits upward. Pass a direction in the opts table when registering.
Per-view directions
Register onOpen and onClose callbacks per view. These fire synchronously before the tween plays, so you can pre-populate content before a frame is visible.
View lifecycle callbacks
If a view's frame contains a child named CloseButton (TextButton), RouterService automatically connects MouseButton1Click to close the current view — no manual wiring needed.
RouterService.Navigate() accepts an opts table with onBefore and onAfter callbacks. onBefore fires with the old and new view names before any tween starts. onAfter fires after the new view opens.
Navigate with callbacks + multiple groups
| Prop | Type | Default | Description |
|---|---|---|---|
| RegisterView | (group: string, name: string, frame: Frame, opts?: table) | — | Adds a frame to a named group. Creates the group automatically if it doesn't exist. |
| Navigate | (group: string, name: string, opts?: table) | — | Opens the named view and closes the previously open one. Toggling the current view closes it. |
| GetCurrent | (group: string) -> string? | — | Returns the name of the currently open view in the group, or nil. |
| GetViews | (group: string) -> {string} | — | Returns a list of all registered view names in the group. |
| opts.direction | "left" | "right" | "up" | "down" | "up" | Slide direction for enter/exit animation. |
| opts.tweenTime | number | 0.4 | Duration of the slide tween in seconds. |
| opts.startVisible | boolean | false | If true, the view starts in its natural position rather than offscreen. |
| opts.onOpen | (frame: Frame) -> ()? | nil | Fires when this view begins opening. |
| opts.onClose | (frame: Frame) -> ()? | nil | Fires when this view begins closing. |