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
@@ -13,7 +14,18 @@ A non-modal primitive with overlays that open and close around a DOM element.
13
14
14
15
<Showcasename="hero" />
15
16
16
-
The Qwik UI Popover component is designed to align with the [HTML Popover API Specification](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API). As of now, native support for this API is around `63%`. To ensure consistent behavior across all browsers, Qwik UI provides a `polyfill` for browsers that do not support the API natively.
17
+
<FeatureList
18
+
features={[
19
+
`"Early" access to MDN's native popover API`,
20
+
'Support across all browsers',
21
+
'Resumable / Lazily executes code on interaction',
22
+
'Top Layer behavior',
23
+
'Opt-in floating behavior',
24
+
'Portal polyfill works across meta-frameworks',
25
+
]}
26
+
/>
27
+
28
+
The Qwik UI Popover component is designed to align with the [HTML Popover API Specification](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API). As of now, native support for this API is around `72%`. To ensure consistent behavior across all browsers, Qwik UI provides a `polyfill` for browsers that do not support the API natively.
17
29
18
30
## What is a Popover?
19
31
@@ -105,6 +117,38 @@ A separate declaration is needed to select popovers in all browsers.
105
117
106
118
> We add a backslash in order to escape the `:` character in CSS. Using `:popover-open` in an unsupported browser results in an invalid selector.
107
119
120
+
### Cross-browser Animations
121
+
122
+
Entry and exit animations have often been a frustrating experience. Especially trying to animate between `display: none`, a discrete property.
123
+
124
+
Until recently, discrete properties were not animatable. Luckily, there's [new properties to CSS](https://developer.chrome.com/blog/entry-exit-animations) that solve this problem.
125
+
126
+
The browser support for these is similar to support of the popover API. That said, the Qwik UI team has done an awesome job of managing animations on polyfill browsers for you using the `popover-showing` and `popover-closing` classes.
/* on new-line so the declaration is valid in all browsers */
133
+
transition-behavior: allow-discrete;
134
+
135
+
/* starting style for all browsers */
136
+
opacity: 0;
137
+
}
138
+
139
+
.popover-showing {
140
+
opacity: 1;
141
+
}
142
+
143
+
.popover-closing {
144
+
opacity: 0;
145
+
}
146
+
```
147
+
148
+
Above is an example of a transition that works across browsers. The `allow-discrete` property allows us to transition both display and overlay. Overlay is a property that allows us to transition top-layer behavior.
149
+
150
+
> In the rare case of a browser supporting the popover API, but not the overlay property, the element functionality is the same but does not transition.
151
+
108
152
## Popovertarget
109
153
110
154
To add a popover trigger, it can be done similar to the native API, using the `popovertarget` attribute along with the corresponding popover id.
To use the popover API with floating elements, you can add the `floating={true}` prop to the Popover component. This API enables the use of JavaScript to dynamically position the listbox using the `top` & `left` absolute properties.
171
215
172
-
> Setting `floating={true}` will add 8-10 or so kb, we currently use javascript to float items, and have tried to make it as minimal and incremental as possible for the upcoming anchor API.
216
+
> Enabling the `floating={true}`property will introduce a slight increase in code size, as we currently utilize JavaScript to implement floating items. We've strived to keep it as minimal as possible, but powerful in building complex components in anticipation of the forthcoming anchor API.
173
217
174
218
To float an element, it must have an anchored element to latch onto. This can be done with the `anchorRef` prop.
0 commit comments