Skip to main content

Home > @jsplumbtoolkit/browser-ui > Surface > positionElementAt

Surface.positionElementAt() method

Positions a DOM element at a given X,Y on the canvas, in canvas coordinates (meaning it takes into account the current zoom and pan). This is not intended for use with elements the surface is managing: it is designed to be used with elements such as pop-ups that you may wish to position relative to the content in your canvas.

Signature:

positionElementAt(el: Element, x: number, y: number, xShift?: number, yShift?: number, ensureOnScreen?: boolean): void;

Parameters

ParameterTypeDescription
elElementElement to position.
xnumberX location on canvas to move element's left edge to.
ynumberY location on canvas to move element's top edge to.
xShiftnumberOptional absolute number of pixels to shift the element by in the x axis after calculating its position relative to the canvas. Typically you'd use this to place something other than the top left corner of your element at the desired location.
yShiftnumberOptional absolute number of pixels to shift the element by in the y axis after calculating its position relative to the canvas.
ensureOnScreenbooleanIf true, will ensure that x and y positions are never negative.

Returns:

void