useGoTo
Commons
stable
Returns a scrollTo function that smoothly scrolls a container or the window to a target element, component instance, CSS selector, or numeric offset. Supports both vertical and horizontal scrolling, RTL awareness, and custom easing/duration options.
API
Signature
Signature TypeScript complète extraite du fichier du composable.
useGoTo reads RTL direction from the global locale and the injected IGoToInstance. Per-call options are deep-merged with the instance defaults, so you can customise the duration globally and override it for specific calls.
Interfaces consommées
IGoToOptions
IGoToInstance
API
Paramètres
Paramètres d'entrée acceptés par ce composable.
- _optionsPartial<IGoToOptions>{}
- optionsPartial<IGoToOptions>
- Default options applied to every go() call made through this instance. Can be overridden per-call.
- options.durationnumber300
- Scroll animation duration in milliseconds.
- options.easingTEasingFunction | string'easeInOutCubic'
- Easing function name or a custom function (t: number) => number controlling the animation curve.
- options.offsetnumber0
- Pixel offset applied to the final scroll position (positive = scroll further, negative = stop earlier).
- options.containerComponentPublicInstance | HTMLElement | string'html'
- Scrollable container element or selector. Defaults to the document root.
API
Valeurs de retour
Propriétés et méthodes exposées par l'objet retourné par le composable.
- go
- Scroll vertically to the target. Accepts a Vue component instance, an HTMLElement, a CSS selector string, or a numeric pixel offset.
- go.horizontal
- Scroll horizontally to the target using the same resolution logic as go().
Usage
Exemples
Extraits de code prêts à coller.
Scroll to an anchor element
Scroll to top with custom easing
Horizontal scroll inside a container