Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: optimize animation with will-change #177

Merged
merged 2 commits into from
Jan 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/react/src/components/Card/CardContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ const Footer = styled('footer').attrs({ className: classNames.url })`
const Author = styled(CardText)`
opacity: 0.75;
transition: opacity ${transition.medium};
will-change: opacity;

.${classNames.main}:hover & {
opacity: 1;
Expand All @@ -95,6 +96,7 @@ const PoweredBy = styled('span').attrs({ title: 'microlink.io' })`
display: block;
margin-left: 15px;
transition: filter ${transition.medium}, opacity ${transition.medium};
will-change: filter, opacity;
&:not(:hover) {
filter: grayscale(100%);
opacity: 0.75;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const BottomControls = styled('div')`
justify-content: center;
align-items: center;
transition: opacity ${transition.medium};
will-change: opacity;

.${classNames.main}:not(:hover) & {
opacity: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const MediaButton = styled('div')`
backface-visibility: hidden;
filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
transition: transform ${transition.short};
will-change: transform;

> svg {
display: block;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const ProgressBar = styled('div').attrs(({ progress }) => ({
bottom: 0;
background: #e1e8ed;
height: ${props => getProgressBarSize(props)}px;
transition: opacity ${transition.medium}, background ${transition.medium};
transition: background ${transition.medium};
will-change: background;

.${classNames.main}:hover & {
background: #fff;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const OuterWrap = styled('div').attrs({ className: classNames.mediaControls })`
right: 0;
bottom: 0;
transition: background ${transition.long};
will-change: background;

.${classNames.main}:hover & {
background: rgba(0, 0, 0, 0.35);
Expand All @@ -39,6 +40,7 @@ const InnerWrap = styled('div')`
justify-content: center;
z-index: 2;
transition: opacity ${transition.medium};
will-change: opacity;

.${classNames.main}:not(:hover) & {
opacity: ${({ opacity = 0 }) => opacity};
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/Card/CardWrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const contrastStyle = ({ backgroundColor, color }) => css`
background-color: ${backgroundColor};
border-color: ${color};
transition-property: filter;
will-change: filter;

&&& {
color: ${color};
Expand All @@ -24,15 +25,14 @@ const contrastStyle = ({ backgroundColor, color }) => css`
const largeStyle = css`
flex-direction: column;
height: ${HEIGHT};
transition-property: background, border-color, height;

${media.mobile`
height: calc(${HEIGHT} * 7/9);
`};
`

const hoverStyle = css`
transition-property: background, border-color;
will-change: background, border-color;
&:hover {
background: #f5f8fa;
border-color: rgba(136, 153, 166, 0.5);
Expand Down
Loading