Skip to content

Commit d766ecb

Browse files
committed
Catch animation errors for ::backdrop
1 parent dc5b15c commit d766ecb

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

src/client/lazy-app/Modal/index.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,14 @@ export default class Modal extends Component<Props, State> {
5656
{ duration: 250, easing: 'ease' },
5757
);
5858
// animate modal::backdrop
59-
animateTo(this.dialogElement, [{ opacity: 0 }, { opacity: 1 }], {
60-
duration: 250,
61-
easing: 'linear',
62-
pseudoElement: '::backdrop',
63-
});
59+
// some browsers don't support ::backdrop, catch those errors
60+
try {
61+
animateTo(this.dialogElement, [{ opacity: 0 }, { opacity: 1 }], {
62+
duration: 250,
63+
easing: 'linear',
64+
pseudoElement: '::backdrop',
65+
});
66+
} catch (e) {}
6467
this.setState({ shown: true });
6568
}
6669

@@ -75,11 +78,14 @@ export default class Modal extends Component<Props, State> {
7578
{ duration: 250, easing: 'ease' },
7679
);
7780
// animate modal::backdrop
78-
animateTo(this.dialogElement, [{ opacity: 0 }], {
79-
duration: 250,
80-
easing: 'linear',
81-
pseudoElement: '::backdrop',
82-
});
81+
// some browsers don't support ::backdrop, catch those errors
82+
try {
83+
animateTo(this.dialogElement, [{ opacity: 0 }], {
84+
duration: 250,
85+
easing: 'linear',
86+
pseudoElement: '::backdrop',
87+
});
88+
} catch (e) {}
8389
anim.onfinish = this._closeOnTransitionEnd;
8490
}
8591

src/client/lazy-app/util/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ export function animateTo(
1919
) {
2020
const anim = element.animate(to, { ...options, fill: 'both' });
2121
anim.addEventListener('finish', () => {
22-
if (!('pseudoElement' in options && options['pseudoElement']))
22+
// pseudo-elements don't support inline styles at the moment, catch those errors
23+
try {
2324
anim.commitStyles();
25+
} catch (e) {}
2426
anim.cancel();
2527
});
2628
return anim;

0 commit comments

Comments
 (0)