UNPKG

nuxt-anchorscroll

Version:
38 lines (37 loc) 1.55 kB
import { type MaybeRefOrGetter } from 'vue'; import type { AnchorScrollCommonOptions, AnchorScrollVariants } from '../anchorscroll.js'; type AnchorScrollComposableOptions = AnchorScrollVariants | AnchorScrollCommonOptions | undefined; interface ScrollToAnchorOptions { /** * Id of the element on page. First # is stripped */ id?: MaybeRefOrGetter<string>; /** * Selector of element on page */ sr?: MaybeRefOrGetter<string>; } interface AnchorScrollComposables { /** * The function for scroll to anchor. The anchor can be reactive element or its id. * The function can be used within the [`scrollToTop`](AnchorScrollComposables.scrollToTop) * ```html * <div @click="scrollToAnchor(id) || scrollToTop()"> * <!-- Scroll to anchor or to top when its not found --> * </div> * ``` * * @param id Reactive element or id value. First # is stripped. Can be reactive [`ScrollToAnchorOptions`](ScrollToAnchorOptions) * @returns [`true`](true) when scroll to anchor succeed, otherwise [`false`](false) */ scrollToAnchor: (id: MaybeRefOrGetter<ScrollToAnchorOptions | HTMLElement | string>) => boolean; /** * The function for scroll to top. Can be used as shortcut */ scrollToTop: () => void; } /** * Produce composables with provided settings (can be reactive). */ export declare const useAnchorScroll: (options?: MaybeRefOrGetter<AnchorScrollComposableOptions>) => AnchorScrollComposables; export {};