Skip to content

Instantly share code, notes, and snippets.

@mobeets
Last active December 27, 2015 23:19
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 mobeets/7405170 to your computer and use it in GitHub Desktop.
Save mobeets/7405170 to your computer and use it in GitHub Desktop.
Render words in two single-quotes with a GIF-like shadow dance.
$(document).ready(function(){
var isNotDancing = true;
function makeItDance() {
$(".quoted").animate({ top: "0%"}, 300, 'linear', function() {
$(this).css("top", "0%"); // dummy animation...i.e. shameless hack
if (isNotDancing){
$('.quoted').addClass("dancing");
isNotDancing = false;
}
else {
$('.quoted').removeClass("dancing");
isNotDancing = true;
}
makeItDance();
});
}
var regex = /\'\'([^\'\']+)\'\'/g;
$("body *").html(function(i, val) {
return val.replace(regex, "<span class='quoted normal'>$1</span>")
}).promise().done(function(){
makeItDance();
});
});
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles.css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="dance.js"></script>
</head>
<body>
<div>
Add two single quotes around a ''word'' or ''multiple words'' inside a div to make it dance.
</div>
(Or, wrap the word in a span with the class <span class="quoted normal">quoted normal</span>.)
</body>
</html>
.quoted{
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
.normal{
color: black;
}
.dancing{
color: gray;
text-shadow:0px 0px 0 rgb(230,230,230),1px 1px 0 rgb(215,215,215), 2px 2px 0 rgb(200,200,200),3px 3px 2px rgba(0,0,0,0),3px 3px 1px rgba(0,0,0,0.5),0px 0px 2px rgba(0,0,0,.2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment