feat(core): add slider dom (#613)

This commit is contained in:
rahim
2026-02-26 11:11:58 +11:00
committed by GitHub
parent fbf888fda3
commit 4c7d287d35
20 changed files with 1331 additions and 341 deletions
+1
View File
@@ -1,4 +1,5 @@
export type { StateAttrMap } from '../../core/ui/types';
export { applyElementProps } from './element-props';
export { logMissingFeature } from './log';
export { getPercentFromPointerEvent } from './pointer';
export { applyStateDataAttrs, getStateDataAttrs } from './state-data-attrs';
+21
View File
@@ -0,0 +1,21 @@
import { clamp } from '@videojs/utils/number';
/** Convert a pointer event position to a 0100 percent along an element's rect. */
export function getPercentFromPointerEvent(
event: { clientX: number; clientY: number },
rect: DOMRect,
orientation: 'horizontal' | 'vertical',
isRTL: boolean
): number {
let ratio: number;
if (orientation === 'vertical') {
ratio = 1 - (event.clientY - rect.top) / rect.height;
} else if (isRTL) {
ratio = (rect.right - event.clientX) / rect.width;
} else {
ratio = (event.clientX - rect.left) / rect.width;
}
return clamp(ratio * 100, 0, 100);
}