import { BehaviorSubjectable } from '../abstract/behavior.subjectable'; import { BehaviorSubject } from '../../node_modules/rxjs'; /** * ScrollPositionSubject * ===================== * * ## Usage * * By default the class will observe the window object... * * ```typescript * import { * ScrollPositionSubject * } from '@mralexandernickel/frontend-subjects/dist/scroll.position/scroll.position'; * * export default new ScrollPositionSubject(); * ``` * * ...if you want to observe the scroll-position of a regular element, you can * do this by passing the target-element to the constructor... * * ```typescript * import { * ScrollPositionSubject * } from '@mralexandernickel/frontend-subjects/dist/scroll.position/scroll.position'; * * const targetElement = document.getElementById('your-shiny-element'); * export default new ScrollPositionSubject(targetElement); * ``` * * ...at last you can subscribe to this scroll-position wherever and as often * as you like, without creating new event-listeners all the time 🚀 * * ```typescript * import ScrollPosition from './ScrollPosition'; * ScrollPosition.get().subscribe(scrollPosition => { * console.log('ScrollPosition is now:', scrollPosition); * }); * ``` */ export declare class ScrollPositionSubject extends BehaviorSubjectable { private targetElement; /** * The scroll-position on y-axis of this.targetElement */ protected subject: BehaviorSubject; /** * @constructor */ constructor(targetElement?: HTMLElement | Window); /** * Get the scroll-position on y-axis based on the type of this.targetElement * @return {number} */ private getScrollYPosition; /** * Callback function for the ScrollSubject * @return {void} */ private scrollHandler; }