forked from reactbkk/2.0.0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request reactbkk#83 from zapkub/feature/css-crossfade-images
💄 Add crossfade effect on Hero images reactbkk#1
- Loading branch information
Showing
6 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
|
||
.vscode | ||
# created by git-ignore | ||
# Logs | ||
logs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Simple crossfade images | ||
// credit: http://css3.bradshawenterprises.com/cfimg/ | ||
|
||
const images = [ | ||
'static/hero-bg.jpg', | ||
'static/hero-bg-2.jpg', | ||
'static/hero-bg-3.jpg' | ||
] | ||
|
||
export default () => ( | ||
<div className='container'> | ||
{images.map(image => { | ||
return <div key={image} className='image' style={{ backgroundImage: `url(${image})` }} /> | ||
})} | ||
<style jsx>{` | ||
.container { | ||
top: 0; | ||
left:0; | ||
bottom:0; | ||
overflow:hidden; | ||
right:0; | ||
position: absolute; | ||
} | ||
.image { | ||
top: 0; | ||
left:0; | ||
bottom:0; | ||
right:0; | ||
background-size: cover; | ||
background-position: center center; | ||
position: absolute; | ||
animation: SimpleCrossfade 12s linear infinite 0s; | ||
transform-origin: center; | ||
} | ||
@keyframes SimpleCrossfade { | ||
0% { opacity:1; transform: scale(1); } | ||
25% { opacity:1; } | ||
33.3333% { opacity:0; transform: scale(1.05); } | ||
50% { transform: scale(1); } | ||
91.66667% { opacity: 0; } | ||
100% { opacity:1; } | ||
} | ||
.image:nth-of-type(1) { | ||
animation-delay: 7s; | ||
} | ||
.image:nth-of-type(2) { | ||
animation-delay: 3s; | ||
} | ||
.image:nth-of-type(3) { | ||
animation-delay: -1s; | ||
} | ||
`}</style> | ||
</div>) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.