Skip to content

Commit aad2a1f

Browse files
authored
feat(dimmer): use modern blurring to improve performance
The blurring dimmer is inperformant because every single node inside the dimmable context is blurred separately which takes lots of time. It also causes positioning glitches when applied (Try the blurring example at fomantic-ui.com/modules/modal.html#dimmer-variations and see the sidebar suddenly vanishes!) Additionally when used in modals it is not nicely animated when the modal hides. This PR switches from the old filter approach on each single node to the modern backdrop-filer approach on the dimmer itself only which is much more performant and nicely animates now. For each browser not supporting this technique, the old behavior will still apply as before.
1 parent 8672140 commit aad2a1f

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/definitions/modules/dimmer.less

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,21 @@ body.dimmable > .dimmer {
180180
Blurring
181181
---------------*/
182182

183-
.blurring.dimmable > :not(.dimmer) {
184-
filter: @blurredStartFilter;
185-
transition: @blurredTransition;
186-
}
187-
.blurring.dimmed.dimmable > :not(.dimmer):not(.popup) {
188-
filter: @blurredEndFilter;
183+
@supports (not (-webkit-backdrop-filter: none)) and (not (backdrop-filter: none)) {
184+
.blurring.dimmable > :not(.dimmer) {
185+
filter: @blurredStartFilter;
186+
transition: @blurredTransition;
187+
}
188+
.blurring.dimmed.dimmable > :not(.dimmer):not(.popup) {
189+
filter: @blurredEndFilter;
190+
}
189191
}
190192

191193
/* Dimmer Color */
192194
.blurring.dimmable > .dimmer {
193195
background: @blurredBackgroundColor;
196+
-webkit-backdrop-filter: @blurredEndFilter;
197+
backdrop-filter: @blurredEndFilter;
194198
}
195199
.blurring.dimmable > .inverted.dimmer {
196200
background: @blurredInvertedBackgroundColor;

src/themes/default/modules/dimmer.variables

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
@duration: 0.5s;
1414
@transition:
15-
background-color @duration linear
15+
all @duration linear
1616
;
1717
@zIndex: 1000;
1818
@textAlign: center;

0 commit comments

Comments
 (0)