Skip to content
EliteChart

clampMenuPosition

Documentation


Documentation / @elitechart/core / clampMenuPosition

code
function clampMenuPosition(
   pos, 
   mw, 
   mh, 
   cw, 
   ch, 
   padding?): ContextMenuPosition;

Defined in: ui/drawing-context-menu.ts:100

Clamp pos so the menu (mw×mh) stays inside the container (cw×ch). Prefers the requested position; nudges it left/up if it would overflow the right/bottom edge.

Parameters

pos

ContextMenuPosition

mw

number

mh

number

cw

number

ch

number

padding?

number = 4

Returns

ContextMenuPosition

Example

code
import { clampMenuPosition } from '@elitechart/core';
const safe = clampMenuPosition({ x: 760, y: 460 }, 200, 120, 800, 480);