Angular Common - Object Structures - positionConfig
Assign this object to the position property of an overlay UI component (Popup, Popover, Tooltip, etc.).
To position an element, specify the my, at, and of properties. In the following code, the Popup UI component's left side is aligned with the target's right side. This configuration reads as follows: "place my left side at the right side of the #target element."
- <dx-popup ... >
- <dxo-position
- my="left"
- at="right"
- of="#target">
- </dxo-position>
- </dx-popup>
You can use the offset property to further adjust the position.
Possible positions are limited by the Window. To limit them by another element, specify the boundary property. If actual boundaries should be narrower or wider than the boundary element, set the boundaryOffset.
When a specified position exceeds the boundaries, a collision occurs. Use the collision property to specify how such collisions should be resolved.
at
Specifies the target element's side or corner where the overlay element should be positioned.
To set this property, use an object with the x and y fields. These fields specify the target element's horizontal and vertical sides, respectively. Alternatively, you can use a string shortcut from the accepted values list.
- <dx-popup ... >
- <dxo-position ...
- at="left top">
- <!-- or -->
- <dxo-at x="left" y="top"></dxo-at>
- </dxo-position>
- </dx-popup>
boundary
The boundary element limits possible positions for the overlay element. The default boundary element is Window. If actual boundaries should be narrower or wider than the boundary element, set the boundaryOffset. When a specified position exceeds the boundaries, a collision occurs.
For information on accepted value types, refer to the of property description.
boundaryOffset
Specifies the offset of boundaries from the boundary element.
The offset is specified in pixels. To set this property, use an object with the x and y fields. These fields specify horizontal and vertical offsets, respectively. Alternatively, you can use a string value that indicates the offsets separated by a whitespace character. A positive offset narrows the boundaries; a negative offset widens the boundaries.
In the following code, left and right boundaries are narrowed (x is 50), but top and bottom boundaries are widened (y is -50).
- <dx-popup ... >
- <dxo-position ...
- boundaryOffset="50 -50">
- <!-- or -->
- <dxo-boundary-offset [x]="50" [y]="-50"></dxo-boundary-offset>
- </dxo-position>
- </dx-popup>
collision
Specifies how to resolve collisions - when the overlay element exceeds the boundary element.
You can use the following collision resolution algorithms:
"flip"
Move the overlay element to the opposite side of the target if that side has more space."fit"
Move the overlay element to the inside of the boundary element."flipfit"
First apply "flip", then "fit"."none"
Ignore the collision.
To set the collision property, use an object with the x and y fields. These fields specify how to resolve horizontal and vertical collisions, respectively. Alternatively, you can use a string shortcut from the accepted values list.
- <dx-popup ... >
- <dxo-position ...
- collision="flip none">
- <!-- or -->
- <dxo-collision x="flip" y="none"></dxo-collision>
- </dxo-position>
- </dx-popup>
my
Specifies the overlay element's side or corner to align with a target element.
To set this property, use an object with the x and y fields. These fields specify the overlay element's horizontal and vertical sides, respectively. Alternatively, you can use a string shortcut from the accepted values list.
- <dx-popup ... >
- <dxo-position ...
- my="left top">
- <!-- or -->
- <dxo-my x="left" y="top"></dxo-my>
- </dxo-position>
- </dx-popup>
of
This property accepts the following value types:
CSS selector (or jQuery selector if jQuery is used)
app.component.html- <dx-popup ... >
- <dxo-position
- of="#target">
- </dxo-position>
- </dx-popup>
-
app.component.htmlapp.component.ts
- <dx-popup>
- <dxo-position
- [of]="getWindow()">
- </dxo-position>
- </dx-popup>
- import { Component } from '@angular/core';
- @Component({
- selector: 'app-root',
- templateUrl: './app.component.html',
- styleUrls: ['./app.component.css']
- })
- export class AppComponent {
- getWindow() {
- return window;
- }
- }
EventObject (or jQuery.Event if jQuery is used)
The overlay element is positioned at the event.pageX and event.pageY coordinates. In the following example, the Popover UI component is positioned at the point where the user has clicked.
app.component.htmlapp.component.ts- <a id="target" (click)="eventHandler($event, item)">Details</a>
- <dx-popover>
- <dxo-position
- [of]="target">
- </dxo-position>
- </dx-popover>
- import { Component } from '@angular/core';
- @Component({
- selector: 'app-root',
- templateUrl: './app.component.html',
- styleUrls: ['./app.component.css']
- })
- export class AppComponent {
- eventHandler($event, item) {
- this.target = $event;
- }
- }
The following value types are more suitable for jQuery:
-
index.js
- $(function() {
- $("#popupContainer").dxPopup({
- // ...
- position: {
- of: $("#target")
- }
- });
- });
-
index.js
- $(function() {
- $("#popupContainer").dxPopup({
- // ...
- position: {
- of: document.getElementById("#target")
- }
- });
- });
offset
The offset is specified in pixels. To set this property, use an object with the x and y fields. These fields specify horizontal and vertical offsets, respectively. Alternatively, you can use a string value that indicates the offsets separated by a whitespace character. A positive offset shifts the element to the right or down; a negative offset shifts it to the left or up.
In the following code, the overlay element is shifted 50 pixels to the right and 25 pixels up.
- <dx-popup ... >
- <dxo-position ...
- offset="50 -25">
- <!-- or -->
- <dxo-offset [x]="50" [y]="-25"></dxo-offset>
- </dxo-position>
- </dx-popup>
If you have technical questions, please create a support ticket in the DevExpress Support Center.