@dotcms/analytics
Version:
Official JavaScript library for Content Analytics with DotCMS.
27 lines (26 loc) • 1.23 kB
TypeScript
import { ViewportMetrics } from '../../shared/models';
/**
* Calculates the visibility ratio of an element in the viewport
* @param element - The HTML element to check
* @returns A number between 0 and 1 representing the visible percentage
*/
export declare function calculateElementVisibilityRatio(element: HTMLElement): number;
/**
* Calculates the offset percentage of an element from the top of the viewport
* @param element - The HTML element to check
* @returns Percentage value (can be negative if above viewport)
*/
export declare function calculateViewportOffset(element: HTMLElement): number;
/**
* Checks if an element meets a specific visibility threshold
* @param element - The HTML element to check
* @param threshold - The required visibility ratio (0.0 to 1.0)
* @returns True if the element meets or exceeds the threshold
*/
export declare function isElementMeetingVisibilityThreshold(element: HTMLElement, threshold: number): boolean;
/**
* Gets comprehensive viewport metrics for an element
* @param element - The HTML element to analyze
* @returns Object containing offset percentage and visibility ratio
*/
export declare function getViewportMetrics(element: HTMLElement): ViewportMetrics;