mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-12 11:38:13 -07:00
website_next: part 12
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user