Skip to content
This repository was archived by the owner on Apr 14, 2020. It is now read-only.

Commit ec29c7c

Browse files
author
Michael Dougall
committed
fix(reveal): fixes reveal in safari
1 parent 68d5b60 commit ec29c7c

6 files changed

Lines changed: 25 additions & 10 deletions

File tree

packages/core/src/motions/FocalRevealMove/__docs__/docs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ import Motion, { FocalRevealMove, FocalTarget } from '@element-motion/core';
196196

197197
<Props of={FocalRevealMove} />
198198

199-
## Caveats
199+
## Gotchas
200200

201201
Reveal works by default modifying the width and height of the element,
202202
starting from the [FocalTarget](/focal-target) element.

packages/core/src/motions/ReshapingContainer/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,14 @@ export default class ReshapingContainer extends React.PureComponent<ReshapingCon
165165
/>
166166

167167
{/* Position relative/zIndex needed to position this above the floating background. */}
168-
{children({ style: { position: 'relative', zIndex: 2, maxHeight } })}
168+
{children({
169+
style: {
170+
maxHeight,
171+
zIndex: 2,
172+
// Using position: relative fucks out in Safari with clip-path resulting in clip-path not transitioning
173+
position: 'relative',
174+
},
175+
})}
169176
</ComponentAs>
170177
)}
171178
</Move>

packages/core/src/motions/Reveal/__docz__/docs.mdx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@ import { Reveal } from '@element-motion/core';
2222

2323
<Props of={Reveal} />
2424

25-
## Caveats
25+
## Gotchas
26+
27+
### Collapsing margins
2628

2729
Be careful of collapsing margins when utilising this motion,
2830
they will make the destination element jump around,
2931
probably.
3032
If you're seeing some odd behavior - maybe try a flex container instead.
33+
34+
### Composing with move
35+
36+
When composing with any motion that uses `transform` or `position: relative`,
37+
Reveal will not work in Safari - follow the bug here: https://bugs.webkit.org/show_bug.cgi?id=196731.

packages/core/src/motions/Reveal/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,9 @@ export default class Reveal extends React.Component<RevealProps> {
5757
data.origin.elementBoundingBox
5858
? {
5959
...prevStyles,
60+
WebkitClipPath: `inset(${topOffset}px ${right}px ${bottom}px ${leftOffset}px)`,
6061
clipPath: `inset(${topOffset}px ${right}px ${bottom}px ${leftOffset}px)`,
61-
opacity: 1,
62-
visibility: 'visible',
63-
willChange: combine('clip-path')(prevStyles.willChange),
62+
willChange: combine('clip-path, -webkit-clip-path')(prevStyles.willChange),
6463
}
6564
: undefined,
6665
});
@@ -78,10 +77,11 @@ export default class Reveal extends React.Component<RevealProps> {
7877
setChildProps({
7978
style: prevStyles => ({
8079
...prevStyles,
80+
WebkitClipPath: 'inset(0px)',
8181
clipPath: 'inset(0px)',
82-
transition: combine(`clip-path ${calculatedDuration}ms ${timingFunction}`)(
83-
prevStyles.transition
84-
),
82+
transition: combine(
83+
`-webkit-clip-path ${calculatedDuration}ms ${timingFunction}, clip-path ${calculatedDuration}ms ${timingFunction}`
84+
)(prevStyles.transition),
8585
}),
8686
});
8787

packages/core/src/motions/RevealReshapingContainer/__docz__/docs.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ import { ReshapingContainer } from '@element-motion/core';
118118

119119
<Props of={ReshapingContainer} />
120120

121-
## Caveats
121+
## Gotchas
122122

123123
Be careful of collapsing margins when utilising this motion,
124124
they will make the destination element jump around when revealing,

packages/core/src/motions/RevealReshapingContainer/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export default class RevealReshapingContainer extends React.PureComponent<
6666
render() {
6767
const { children, duration, timingFunction, triggerKey } = this.props;
6868

69+
// The Move transition using transform fucks out in Safari with clip-path resulting in clip-path not transitioning
6970
return (
7071
<ReshapingContainer {...this.props}>
7172
{reshaping => (

0 commit comments

Comments
 (0)