reearth.popup
The reearth.popup
namespace defines the structure and capabilities of popup dialog components within reearth
.
Methods
show
The show method displays a popup with custom HTML content at a specified position relative to the extension widget or block. The popup’s appearance, location, and offset can be configured, making it flexible for various UI needs.
Syntax
Parameters
html
Type: string
A string of HTML content to be displayed within the popup.
options
Optional
An object with properties to customize the popup’s appearance and placement:
Type:
width?: number | string;
: Specifies the width of the popup.height?: number | string;
: Specifies the height of the popup.position?: PopupPosition;
: Specifies the popup’s position relative to a reference point or an element.
offset?: PopupOffset
: Defines additional spacing or offset for the popup from its positioned location.
Return Value:
None (void)
. The method performs its operation without returning a value.
Example
postMessage
This enables sending messages to the popup iframe. This function is useful for communication in scenarios where a popup needs to get information from the extension script.
Syntax
Parameters
message
Type: any
The message to be sent.
Return Value:
None (void)
. The method performs its operation without returning a value.
Example
update
This allows users to modify the appearance and position of the popup iframe. Users can dynamically adjust properties such as the popup’s width, height, position, and offset without needing to recreate the popup.
Syntax
Parameters
options
An object that contains properties to update the popup’s size, position, and offset.
Type:
width?: number | string;
: Sets the popup’s new width.height?: number | string;
: Sets the popup’s new height.position?: PopupPosition;
: Specifies the new popup’s position relative to a reference point or an element.
offset?: PopupOffset;
: Adjusts the spacing or offset of the popup from its positioned location.
Return Value:
None (void)
. The method performs its operation without returning a value.
Example
close
This method provides a simple way to programmatically close a currently active popup. Users can dismiss the popup based on task completion, logical conditions or other user actions.
Syntax
Parameters
None
Return Value:
None (void)
. The method performs its operation without returning a value.
Example
Events
close
The close event is triggered when the popup in reearth
is closed. This event allows you to execute specific actions, such as cleaning up resources, updating the UI, or notifying other components when the popup is no longer visible.
Syntax
Example
References
PopupPosition
The PopupPosition
type controls where the popup appears relative to the target element. It provides a range of options for positioning the popup above, below, or to the sides of the extension widget or block, with additional options for alignment adjustments (start, center, or end).
top
: Positions the popup directly above the target.
top-start
: Aligns the popup at the top left of the target.
top-end
: Aligns the popup above the target and positions it to the right side of the target.
right
: Aligns the popup directly to the right of the target.
right-start
: Aligns the popup to the right of the target and positions it at the top edge of the target.
right-end
: Aligns the popup to the bottom of the right side of the target.
bottom
: Positions the popup directly below the target.
bottom-start
: Aligns the popup below the target, positioned to the left.
bottom-end
: Aligns the popup below the target, positioned to the right.
left
: Positions the popup directly to the left of the target.
left-start
: Aligns the popup to the top of the left side of the target.
left-end
: Aligns the popup to the bottom of the left side of the target.
PopupOffset
The PopupOffset
type allows users to control the popup’s distance from the extension widget or block. It provides two options: A number that adjusts the offset along the main axis, and an object for more detailed control over different axes, including main, cross, and alignment axes.
Options
Number
- A single number shifts the popup along its main axis, either toward or away from the target.
- Example: 10 shifts the popup 10 pixels along the main axis.
Object
An object providing fine control with the following properties:
mainAxis?: number
: Adjusts the popup’s distance from the target along the main axis. Positive values move the popup farther from the target, negative values bring it closer.
crossAxis?: number
: Adjusts the popup’s distance along the cross axis, perpendicular to the main axis.Positive values move the popup in one direction, negative values move it in the opposite direction, depending on the orientation.
alignmentAxis?: number | null
: The same axis as crossAxis
but applies only to aligned placements and inverts the end
alignment. When set to a number, it overrides the crossAxis
value. A positive number will move the floating element in the direction of the opposite edge to the one that is aligned, while a negative number the reverse.