Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Helfull/3ffa0b360ce69a9f28ff2deea00698d4 to your computer and use it in GitHub Desktop.
Save Helfull/3ffa0b360ce69a9f28ff2deea00698d4 to your computer and use it in GitHub Desktop.
function chatbubble() {
var animationEnd = "webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend";
var str = "OMG I just did a thing! and now holy shit is this even longer thing!";
var x = str.length;
x = x * 50;
// Put in the text the supporter wants to say
$('#cbinntertext').html(str);
// show the bubble
$('#cb').show();
// animate the bubble
// 1. Add the bounceIn
$('#cb').addClass('animated bounceIn').one(animationEnd, function() {
setTimeout(function() {
// After a set amount of time remove the BounceIn
$('#cb').removeClass('bounceIn');
// and add the bounceOut
$('#cb').addClass('bounceOut').one(animationEnd, function() {
// once the bounceOut animation is finished
// hide the bubble and remove the animation classes
$('#cb').hide();
$('#cb').removeClass('animated bounceOut');
});
}, x);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment