tinymce.geom.Rect

Contains various tools for rect/position calculation.

Summary

Methods

Name Summary Defined by

clamp()

Returns a rect clamped within the specified clamp rect. This forces the rect to be inside the clamp rect.

Rect

create()

Creates a new rectangle object.

Rect

findBestRelativePosition()

Tests various positions to get the most suitable one.

Rect

fromClientRect()

Creates a new rectangle object form a clientRects object.

Rect

inflate()

Inflates the rect in all directions.

Rect

intersect()

Returns the intersection of the specified rectangles.

Rect

relativePosition()

Returns the rect positioned based on the relative position name to the target rect.

Rect

Methods

clamp()

clamp(rect: Rect, clampRect: Rect, fixedSize: Boolean): Rect

Returns a rect clamped within the specified clamp rect. This forces the rect to be inside the clamp rect.

Parameters

  • rect (Rect) - Rectangle to force within clamp rect.

  • clampRect (Rect) - Rectable to force within.

  • fixedSize (Boolean) - True/false if size should be fixed.

Return value

  • Rect - Clamped rect.


create()

create(x: Number, y: Number, w: Number, h: Number): Rect

Creates a new rectangle object.

Parameters

  • x (Number) - Rectangle x location.

  • y (Number) - Rectangle y location.

  • w (Number) - Rectangle width.

  • h (Number) - Rectangle height.

Return value

  • Rect - New rectangle object.


findBestRelativePosition()

findBestRelativePosition(rect: Rect, targetRect: Rect, constrainRect: Rect, rels: Array)

Tests various positions to get the most suitable one.

Parameters

  • rect (Rect) - Rect to use as source.

  • targetRect (Rect) - Rect to move relative to.

  • constrainRect (Rect) - Rect to constrain within.

  • rels (Array) - Array of relative positions to test against.


fromClientRect()

fromClientRect(clientRect: ClientRect): Rect

Creates a new rectangle object form a clientRects object.

Parameters

  • clientRect (ClientRect) - DOM ClientRect object.

Return value

  • Rect - New rectangle object.


inflate()

inflate(rect: Rect, w: Number, h: Number): Rect

Inflates the rect in all directions.

Parameters

  • rect (Rect) - Rect to expand.

  • w (Number) - Relative width to expand by.

  • h (Number) - Relative height to expand by.

Return value

  • Rect - New expanded rect.


intersect()

intersect(rect: Rect, cropRect: Rect): Rect

Returns the intersection of the specified rectangles.

Parameters

  • rect (Rect) - The first rectangle to compare.

  • cropRect (Rect) - The second rectangle to compare.

Return value

  • Rect - The intersection of the two rectangles or null if they don’t intersect.


relativePosition()

relativePosition(rect: Rect, targetRect: Rect, rel: String)

Returns the rect positioned based on the relative position name to the target rect.

Parameters

  • rect (Rect) - Source rect to modify into a new rect.

  • targetRect (Rect) - Rect to move relative to based on the rel option.

  • rel (String) - Relative position. For example: tr-bl.