Skip to content

Instantly share code, notes, and snippets.

@chrisvoncsefalvay
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisvoncsefalvay/9584642 to your computer and use it in GitHub Desktop.
Save chrisvoncsefalvay/9584642 to your computer and use it in GitHub Desktop.
Fade/blur focus animation
$animation-width: 1024px
$animation-height: 768px
// Animation keyframes
@-webkit-keyframes fio
0%, 100%
opacity: 0.2
-webkit-transform: scale(0.2, 0.2)
-webkit-filter: blur(3px)
50%
opacity: 1
-webkit-transform: scale(1,1)
-webkit-filter: blur(0)
// Styling
.animated
font:
family: "Helvetica"
size: 36px
.item
position: absolute
opacity: 0
-webkit-animation:
direction: normal
duration: 8s
iteration-count: infinite
name: fio
timing-function: ease-in-out
@for $i from 1 through 10
&:nth-of-type(#{$i})
left: random($animation-width) + px
top: random($animation-height) + px
-webkit-animation-delay: random(500)/100 + s
<div class="animated">
<div class="item">Item One</div>
<div class="item">Item Two</div>
<div class="item">Item Three</div>
<div class="item">Item Four</div>
<div class="item">Item Five</div>
<div class="item">Item Six</div>
<div class="item">Item Seven</div>
<div class="item">Item Eight</div>
<div class="item">Item Nine</div>
<div class="item">Item Ten</div>
</div>
@peteaylward
Copy link

You could use nth-child in the sass to avoid having to give numerical class names to the items, and also do 0%,100% … to save duplicating the two identical animation states.

@chrisvoncsefalvay
Copy link
Author

@peteaylward Thanks Pete ;) on Sunday, no less!
Also a shoutout to @pandalion for her comments on Twitter ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment