Created
August 23, 2013 13:10
-
-
Save kyleturman/6319195 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
strong { | |
display: inline-block; | |
font-weight: normal; | |
overflow: hidden; | |
margin-top: 2px; | |
position: relative; | |
vertical-align: top; | |
span { | |
display: block; | |
position: absolute; | |
white-space: pre; | |
} | |
} |
This file contains hidden or 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
<h1> | |
SOLVING THE AGE-OLD QUESTION OF<br> | |
<q>“</q>WHERE SHOULD WE EAT <strong><span>ON Friday?</strong><q>”</q> | |
</h1> |
This file contains hidden or 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
times = ["Tonight?", "Tomorrow?", "This Weekend?", "Next Week?", "Right Now?"] | |
timeChangeCount = 5 | |
# Get the span and set initial width | |
$span = $tagline.find("span") | |
$when = $tagline.find("strong").css {width: $span.width(), height: $span.height()} | |
changeTime = ()-> | |
if timeChangeCount < times.length | |
$span = $when.find("span") | |
# Create a new span and set it beneath the old one | |
$newSpan = $('<span/>', | |
html: times[timeChangeCount] | |
style: "top:30%;opacity:0" | |
).appendTo($when) | |
# Animate the new width to containing strong | |
$when.animate {width: $newSpan.width(), height: $newSpan.height()}, 250 | |
# Out with old, in with the new | |
$span.animate {opacity:0}, 200, ()-> | |
$newSpan.animate {top:0, opacity:1}, 800, "easeOutElastic", ()-> | |
$span.remove() | |
timeChangeCount++ | |
setTimeout(changeTime, 1500) | |
setTimeout(changeTime, 2000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment