Skip to content
EliteChart

computeToolbarPosition

Documentation


Documentation / @elitechart/core / computeToolbarPosition

code
function computeToolbarPosition(
   bbox, 
   tw, 
   th, 
   cw, 
   ch, 
   gap): {
  x: number;
  y: number;
};

Defined in: ui/floating-toolbar.ts:258

Compute the (left, top) for a toolbar of size tw×th over a bbox, clamped to cw×ch. Default is centered above bbox; flips below if the top would clip against the container's top edge.

Parameters

bbox

ToolbarBBox

tw

number

th

number

cw

number

ch

number

gap

number

Returns

code
{
  x: number;
  y: number;
}

x

code
readonly x: number;

y

code
readonly y: number;

Example

code
import { computeToolbarPosition } from '@elitechart/core';
const { x, y } = computeToolbarPosition(bbox, 220, 32, 800, 480, 10);