import { BehaviorSubjectable } from '../abstract/behavior.subjectable'; export declare const enum ScrollDirections { none = 0, up = 1, down = 2 } export declare const enum ScrollSpeeds { slow = 1, regular = 2, fast = 3 } export declare type ScrollDirection = ScrollDirections.up | ScrollDirections.down | ScrollDirections.none; export declare type ScrollSpeed = ScrollSpeeds.regular | ScrollSpeeds.fast; export interface IScrollInformation { direction: ScrollDirection; speed: ScrollSpeed; } /** * ScrollDirection * =============== * * ## Usage * * ```typescript * import { * ScrollDirectionSubject * } from '@mralexandernickel/frontend-subjects/dist/scroll.direction/scroll.direction'; * * export default new ScrollDirectionSubject(); * ``` * * ```typescript * import ScrollDirection from './ScrollDirection'; * ScrollDirection.get().subscribe(scrollDirection => { * console.log('Direction is now:', scrollDirection); * }); * ``` */ export declare class ScrollDirectionSubject extends BehaviorSubjectable { /** * SetTimeout handle */ private timer; /** * Initial scroll information */ private scrollInformation; /** * Last saved offset of window */ private lastScrollTop; /** * @constructor */ constructor(); /** * Detect if the user has stopped scrolling */ private detectStop; /** * Detect in which direction the user is scrolling * @param scrollTop current scrollTop */ private detectDirection; /** * Detect how fast the user is scrolling * @param scrollTop current scrollTop */ private detectSpeed; /** * Find out if the body been scrolled to top * @param scrollTop current scrollTop position */ static scrolledToTop(scrollTop: number): boolean; /** * Find out if the body been scrolled to bottom * @param scrollTop current scrollTop position */ static scrolledToBottom(scrollTop: number): boolean; /** * Check if one boundary is reached * @param scrollTop current scrollTop position */ static boundaryReached(scrollTop: number): boolean; /** * Reset scroll information */ private reset; /** * Callback function for the onscroll event-listener * @return {void} */ private scrollHandler; }