website_next: part 12

This commit is contained in:
nym21
2026-07-10 12:45:55 +02:00
parent e279116bff
commit 8d43f340a0
11 changed files with 320 additions and 161 deletions
@@ -3,12 +3,12 @@ const OVERLAY_MARGIN = 8;
/**
* @param {HTMLElement} element
* @param {BlockPreviewPointer} point
* @param {BlockPreviewReadoutSize} size
*/
export function placeReadout(element, point) {
export function placeReadout(element, point, size) {
const figure = /** @type {HTMLElement} */ (element.parentElement);
const bounds = figure.getBoundingClientRect();
const width = element.offsetWidth;
const height = element.offsetHeight;
const { width, height } = size;
const minX = Math.min(bounds.width / 2, width / 2 + OVERLAY_MARGIN);
const maxX = Math.max(minX, bounds.width - minX);
const rawX = point.clientX - bounds.left;
@@ -31,3 +31,9 @@ export function placeReadout(element, point) {
* @property {number} clientX
* @property {number} clientY
*/
/**
* @typedef {Object} BlockPreviewReadoutSize
* @property {number} width
* @property {number} height
*/