You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The constraint option controls how the popover flows around its attachment. The value is a list of objects, each representing a different position that the popover can be in relative to the attachment element. The popover will go over this list and find the first constraint which allows the popover to fit on screen.
4
+
5
+
Each object is written like such: `{ popover: '$primary $secondary', attachment: '$primary $secondary' }`.
6
+
7
+
For the popover element, the `$primary` represents the side of the popover where the arrow will be present, and the `$secondary` represents where the arrow sits on the `$primary` side. For instance, the setting of `popover: 'top left'`, will have the arrow on the top left side of the popover.
8
+
9
+
For the attachment element, the `$primary` represents the side of the attachment element where the popover will sit on, and the `$secondary` represents where the arrow points to on the `$primary` attachment side. For instance, the setting of `attachment: 'right top'`, will put the popover on the right side of the attachment and with the arrow pointing to the top portion of the attachment element.
10
+
11
+
The valid values for `$primary` and `$secondary` are `[``top``right``bottom``left``center|middle``]`. You can also choose to omit the `$secondary` value, which will auto-fill with the three logical sides that the `$secondary` value can be in (this is done to reduce code length when designing complex constraints).
12
+
13
+
## Example
14
+
15
+
```javascript
16
+
import { PopoverjsReact } from'popover.js';
17
+
constpopoverOptions= {
18
+
showOn: ['trigger.click'],
19
+
hideOn: ['trigger.click'],
20
+
constraintElement:'scroll',
21
+
constraints: [
22
+
{ popover:'right', attachment:'left' },
23
+
{ popover:'top', attachment:'bottom' },
24
+
{ popover:'bottom', attachment:'top' },
25
+
{ popover:'left', attachment:'bottom' },
26
+
],
27
+
};
28
+
...
29
+
<PopoverjsReact popoverOptions={popoverOptions}>
30
+
<div className="demo-trigger">I am the trigger</div>
31
+
<div className="demo-content">I am the content</div>
0 commit comments