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

Commit

Permalink
fix(reveal): fixes reveal in safari
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdouges committed Jun 6, 2019
1 parent 68d5b60 commit ec29c7c
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ import Motion, { FocalRevealMove, FocalTarget } from '@element-motion/core';

<Props of={FocalRevealMove} />

## Caveats
## Gotchas

Reveal works by default modifying the width and height of the element,
starting from the [FocalTarget](/focal-target) element.
Expand Down
9 changes: 8 additions & 1 deletion packages/core/src/motions/ReshapingContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,14 @@ export default class ReshapingContainer extends React.PureComponent<ReshapingCon
/>

{/* Position relative/zIndex needed to position this above the floating background. */}
{children({ style: { position: 'relative', zIndex: 2, maxHeight } })}
{children({
style: {
maxHeight,
zIndex: 2,
// Using position: relative fucks out in Safari with clip-path resulting in clip-path not transitioning
position: 'relative',
},
})}
</ComponentAs>
)}
</Move>
Expand Down
9 changes: 8 additions & 1 deletion packages/core/src/motions/Reveal/__docz__/docs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,16 @@ import { Reveal } from '@element-motion/core';

<Props of={Reveal} />

## Caveats
## Gotchas

### Collapsing margins

Be careful of collapsing margins when utilising this motion,
they will make the destination element jump around,
probably.
If you're seeing some odd behavior - maybe try a flex container instead.

### Composing with move

When composing with any motion that uses `transform` or `position: relative`,
Reveal will not work in Safari - follow the bug here: https://bugs.webkit.org/show_bug.cgi?id=196731.
12 changes: 6 additions & 6 deletions packages/core/src/motions/Reveal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ export default class Reveal extends React.Component<RevealProps> {
data.origin.elementBoundingBox
? {
...prevStyles,
WebkitClipPath: `inset(${topOffset}px ${right}px ${bottom}px ${leftOffset}px)`,
clipPath: `inset(${topOffset}px ${right}px ${bottom}px ${leftOffset}px)`,
opacity: 1,
visibility: 'visible',
willChange: combine('clip-path')(prevStyles.willChange),
willChange: combine('clip-path, -webkit-clip-path')(prevStyles.willChange),
}
: undefined,
});
Expand All @@ -78,10 +77,11 @@ export default class Reveal extends React.Component<RevealProps> {
setChildProps({
style: prevStyles => ({
...prevStyles,
WebkitClipPath: 'inset(0px)',
clipPath: 'inset(0px)',
transition: combine(`clip-path ${calculatedDuration}ms ${timingFunction}`)(
prevStyles.transition
),
transition: combine(
`-webkit-clip-path ${calculatedDuration}ms ${timingFunction}, clip-path ${calculatedDuration}ms ${timingFunction}`
)(prevStyles.transition),
}),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ import { ReshapingContainer } from '@element-motion/core';

<Props of={ReshapingContainer} />

## Caveats
## Gotchas

Be careful of collapsing margins when utilising this motion,
they will make the destination element jump around when revealing,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default class RevealReshapingContainer extends React.PureComponent<
render() {
const { children, duration, timingFunction, triggerKey } = this.props;

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

0 comments on commit ec29c7c

Please sign in to comment.