import { Point, Rect, Size, PointDescriptor } from 'spase'; import { DirtyInfo, ResponsiveDescriptor, ScrollBreakDescriptor } from '../types/index.js'; import { ScrollDelegate } from './ScrollDelegate.js'; import { UpdateDelegate } from './UpdateDelegate.js'; /** * A {@link StickyScrollDelegate} is subclass of {@link ScrollDelegate} that * allows its scroll target to "stick" to the brower in certain regions, as * defined by its "scroll breaks". When the scroll target is "stuck", it appears * to have stopped moving, hence stuck in place, while the browser scroll bar * continues to move. Only after the browser scrolls past a certain predefined * point will the scroll target "unstick" and start scrolling again. */ export declare class StickyScrollDelegate extends ScrollDelegate { /** * Specifies if the scroll target position should automatically be updated. */ shouldAutoUpdateScrollTarget: boolean; /** * Gets the target element to simulate the scroll on. */ private scrollTargetGetter?; /** * Gets the associated scroll container. */ private scrollContainerGetter?; /** * Definied scroll break descriptors. A scroll break is a point in scrolling * where the target holds its position still until the scroll break length is * surprassed. * * @param info Object containing the minimum position and the maximum * position of the scroll target. */ private scrollBreakGetter?; /** * Creates a new {@link StickyScrollDelegate} instance. * * @param updateHandler The handler to invoke upon every update event. * @param descriptors Map of responsive descriptors. */ constructor(updateHandler: (info: DirtyInfo, delegate: UpdateDelegate) => void, descriptors?: Record); /** * Gets the minimum position of the scroll target. * * @returns Minimum postiion of the scroll target. */ get scrollTargetMinPosition(): Point | null; /** * Gets the maximum position of the scroll target. * * @returns Maximum position of the scroll target. */ get scrollTargetMaxPosition(): Point | null; /** * Sets the scroll target for this delegate. */ set scrollTarget(val: () => HTMLElement | undefined | null); /** * Sets scroll breaks for this delegate. */ set scrollBreaks(val: (info: { minPos: Point; maxPos: Point; }) => ScrollBreakDescriptor); /** * Associates a scroll container to this delegate. */ set scrollContainer(val: () => HTMLElement | undefined | null); /** @inheritdoc */ deinit(): void; /** * Gets the {@link Rect} of a child relative to the scroll target. * * @param index Index of the child. * * @returns The relative {@link Rect}. */ getRelativeRectOfChildAt(index: number): Rect | null; /** * Gets the scroll step relative to a child in the scroll target. * * @param index The index of the child in the scroll target. * @param currStep The current overall scroll step. * * @returns The relative scroll step to the child. */ getRelativeStepOfChildAt(index: number, currStep: Point | PointDescriptor): Point | null; /** * Gets the scroll step relative to a {@link Rect} in the scroll target. * * @param rect The {@link Rect} in the scroll target. * @param currStep The current overall scroll step. * * @returns The relative scroll step to the {@link Rect}. */ getRelativeStepOfRect(rect: Rect, currStep: Point | PointDescriptor): Point | null; /** * Gets the relative step of a horizontal scroll break at the provided index. * * @param index Scroll break index. * @param currStep The current overall scroll step. * * @returns The relative horizontal step. */ getRelativeStepOfHorizontalScrollBreakAt(index: number, currStep: Point | PointDescriptor): number; /** * Gets the relative step of a vertical scroll break at the provided index. * * @param index Scroll break index. * @param currStep The current overall scroll step. * * @returns The relative vertical step. */ getRelativeStepOfVerticalScrollBreakAt(index: number, currStep: Point | PointDescriptor): number; /** @inheritdoc */ protected updateSizeInfo(): void; /** @inheritdoc */ protected updatePositionInfo(reference?: HTMLElement | Window): void; /** * Updates the size of the scroll container, if provided. * * @param size The size to apply to the scroll container. */ protected updateScrollContainerSize(size: Size): void; /** * Updates the scroll target position, if applicable. * * @param position The position to apply to the scroll target. */ protected updateScrollTargetPosition(position: Point): void; /** * Converts a scroll step to a virtual position. A virtual position is a * coordinate in the scroll target that includes all scroll breaks. * * @param step Scroll step. * * @returns The corresponding virtual position. */ protected stepToVirtualPosition(step?: Point): Point | null; /** * Converts a scroll step to a natural position. A natural position is a * coordinate in the scroll target that excludes all scroll breaks. * * @param step Scroll step. * * @returns The corresponding natural position. */ protected stepToNaturalPosition(step?: Point): Point | null; /** * Converts a virtual position to a scroll step. A virtual position is a * coordinate in the scroll target that includes all scroll breaks. * * @param position Virtual position. * * @returns The corresponding scroll step. */ protected virtualPositionToStep(position?: Point): Point | null; /** * Converts a virtual position to a natural position. A virtual position is a * coordinate in the scroll target that includes all scroll breaks, while a * natural position is a coordinate in the scroll target that excludes all * scroll breaks. * * @param position Virtual position. * * @returns The corresponding natural position. */ protected virtualPositionToNaturalPosition(position?: Point): Point | null; /** * Adds up and returns the total of all horizontal scroll break lengths. * * @returns The total of all horizontal scroll break lengths. */ private aggregateHorizontalScrollBreaks; /** * Adds up and returns the total of all vertical scroll break lengths. * * @returns The total of all vertical scroll break lengths. */ private aggregateVerticalScrollBreaks; private aggregateVerticalScrollBreaksBeforeBreakStep; /** * Finds the nearest horizontal scroll break defined for this delegate without * exceeding the provided virtual x-position. * * @param position The virtual x-position. * * @returns The nearest vertical scroll break. */ private findNearestHorizontalScrollBreakByVirtualPosition; /** * Finds the nearest vertical scroll break defined for this delegate without * exceeding the provided virtual y-position. * * @param position The virtual y-position. * * @returns The nearest vertical scroll break. */ private findNearestVerticalScrollBreakByVirtualPosition; /** * Gets all the scroll breaks defined for this delegate, sorted by step. * * @returns Descriptor of scroll breaks. */ private getScrollBreaks; }