• A client x coordinate (e.g. PointerEvent.clientX) as position in a box measured from the box's start: left-to-right from its left edge, right-to-left from its right edge.

    Parameters

    • clientX: number

      x in client (viewport) coordinates

    • boxLeft: number

      the left edge of the box in client coordinates

    • boxWidth: number

      the width of the box

    • rtl: boolean

      right-to-left

    Returns number

    px from the start of the box

    Example

    host.addEventListener("pointerdown", e => {
    const r = host.getBoundingClientRect();
    console.info(toLogicalX(e.clientX, r.left + host.clientLeft, host.clientWidth, true)); // px from the right edge
    });

    Since

    1.1.98