UNPKG

@fastkit/vue-scroller

Version:

A library for controlling the scrolling state of elements and components in Vue applications.

176 lines (175 loc) 7.66 kB
import { ScrollAxis, ScrollDirection, ScrollPosition, ScrollStopper, ScrollToElementAdditionalOffset, ScrollToElementTarget, ScrollToSideTargets, ScrollXDirection, ScrollYDirection, Scroller, ScrollerScrollOptions, ScrollerScrollToElementOptions, ScrollerSetting, ScrollerState } from "@fastkit/scroller"; import { ExtractPropTypes, PropType } from "vue"; import { ExtractPropInput } from "@fastkit/vue-utils"; export * from "@fastkit/scroller"; //#region src/composables/scroller.d.ts type UseScrollerTarget = 'self' | 'body'; interface UseScrollerSetting extends Omit<Partial<ScrollerSetting>, 'el'> { el?: UseScrollerTarget; } declare function useScrollerControl(setting: UseScrollerSetting): { readonly elementRef: import("vue").Ref<HTMLElement | null, HTMLElement | null>; readonly scroller: Scroller; readonly containerHeight: number; readonly containerWidth: number; readonly isDestroyed: boolean; readonly isPending: boolean; readonly isReady: boolean; readonly isRunning: boolean; readonly lastAxis: ScrollAxis; readonly lastDirection: ScrollDirection; readonly lastXDirection: ScrollXDirection; readonly lastYDirection: ScrollYDirection; readonly nowScrolling: boolean; readonly scrollEnabled: boolean; readonly scrollHeight: number; readonly scrollWidth: number; readonly scrollableX: boolean; readonly scrollableY: boolean; readonly state: ScrollerState; scrollBottom: number; scrollLeft: number; scrollRight: number; scrollTop: number; ready(): Promise<void>; element(): HTMLElement | null; start(): Promise<void>; stop(): void; destroy(): void; update(): void; toJSON(): import("@fastkit/scroller").ScrollerObserver; toString(): string; cancel(): void; by(diffX: number, diffY: number, options?: ScrollerScrollOptions): import("@fastkit/scroller").ScrollResult; to(scrollPosition: Partial<ScrollPosition>, options?: ScrollerScrollOptions): import("@fastkit/scroller").ScrollResult; toElement(target: ScrollToElementTarget, options?: ScrollerScrollToElementOptions): import("@fastkit/scroller").ScrollResult; toSide(targets: ScrollToSideTargets, options?: ScrollerScrollOptions): import("@fastkit/scroller").ScrollResult; toTop(options?: ScrollerScrollOptions): import("@fastkit/scroller").ScrollResult; toRight(options?: ScrollerScrollOptions): import("@fastkit/scroller").ScrollResult; toBottom(options?: ScrollerScrollOptions): import("@fastkit/scroller").ScrollResult; toLeft(options?: ScrollerScrollOptions): import("@fastkit/scroller").ScrollResult; toLeftTop(options?: ScrollerScrollOptions): import("@fastkit/scroller").ScrollResult; toLeftBottom(options?: ScrollerScrollOptions): import("@fastkit/scroller").ScrollResult; toRightTop(options?: ScrollerScrollOptions): import("@fastkit/scroller").ScrollResult; toRightBottom(options?: ScrollerScrollOptions): import("@fastkit/scroller").ScrollResult; pushScrollStopper(stopper: ScrollStopper): () => void; removeScrollStopper(stopper: ScrollStopper): void; setScrollToElementAdditionalOffset(offset: ScrollToElementAdditionalOffset | undefined): void; deleteScrollToElementAdditionalOffset(): void; }; type UseScroller = ReturnType<typeof useScrollerControl>; declare function getDocumentScroller(): UseScroller; type ScrollerControl = ReturnType<typeof useScrollerControl>; //#endregion //#region src/components/VScroller.d.ts interface VScrollerSettings extends UseScrollerSetting {} declare const scrollerProps: { settings: { type: PropType<VScrollerSettings | null>; default: null; }; /** * スクロール可能な辺にガイドとして影を表示する場合に設定する */ guide: (BooleanConstructor | NumberConstructor)[]; /** * スクロールするコンテナ要素のクラス名 */ containerClass: StringConstructor; }; type VScrollerProps = ExtractPropInput<typeof scrollerProps>; type VScrollerResolvedProps = ExtractPropTypes<typeof scrollerProps>; /** Scrollability in each direction */ interface ScrollerScrollability { /** Whether you can scroll to the left or not */ left: boolean; /** Whether you can scroll to the right or not */ right: boolean; /** Whether you can scroll to the top or not */ top: boolean; /** Whether you can scroll to the bottom or not */ bottom: boolean; } /** * Combined Scrollability * * The information immediately below is marked as scrollable to account for the margin of the `guide` prop, so `false` may be marked even if the information is actually scrollable. * If you want to check strict scrollability, check the `strict` property. */ interface ScrollerCombinedScrollability extends ScrollerScrollability { /** * Strict scrollability * * Scrollable more than 0px will be marked as valid */ strict: ScrollerScrollability; } interface ScrollerAPI { get scroller(): ScrollerControl; /** * Combined Scrollability * * @see {@link ScrollerCombinedScrollability} */ get scrollable(): ScrollerCombinedScrollability; } declare const _ScrollerI: import("vue").DefineComponent<ExtractPropTypes<{ settings: { type: PropType<VScrollerSettings | null>; default: null; }; /** * スクロール可能な辺にガイドとして影を表示する場合に設定する */ guide: (BooleanConstructor | NumberConstructor)[]; /** * スクロールするコンテナ要素のクラス名 */ containerClass: StringConstructor; }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ExtractPropTypes<{ settings: { type: PropType<VScrollerSettings | null>; default: null; }; /** * スクロール可能な辺にガイドとして影を表示する場合に設定する */ guide: (BooleanConstructor | NumberConstructor)[]; /** * スクロールするコンテナ要素のクラス名 */ containerClass: StringConstructor; }>> & Readonly<{}>, { settings: VScrollerSettings | null; }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>; declare const VScroller: import("@fastkit/vue-utils").TypedComponent<import("@fastkit/vue-utils").ExposedComponent<ScrollerAPI, import("vue").DefineComponent<ExtractPropTypes<{ settings: { type: PropType<VScrollerSettings | null>; default: null; }; /** * スクロール可能な辺にガイドとして影を表示する場合に設定する */ guide: (BooleanConstructor | NumberConstructor)[]; /** * スクロールするコンテナ要素のクラス名 */ containerClass: StringConstructor; }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ExtractPropTypes<{ settings: { type: PropType<VScrollerSettings | null>; default: null; }; /** * スクロール可能な辺にガイドとして影を表示する場合に設定する */ guide: (BooleanConstructor | NumberConstructor)[]; /** * スクロールするコンテナ要素のクラス名 */ containerClass: StringConstructor; }>> & Readonly<{}>, { settings: VScrollerSettings | null; }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>>, {}>; //#endregion export { ScrollerAPI, ScrollerCombinedScrollability, ScrollerControl, ScrollerScrollability, UseScroller, UseScrollerSetting, UseScrollerTarget, VScroller, VScrollerProps, VScrollerResolvedProps, VScrollerSettings, _ScrollerI, getDocumentScroller, scrollerProps, useScrollerControl };