Skip to content

Instantly share code, notes, and snippets.

@britg
Created January 15, 2012 16:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save britg/1616386 to your computer and use it in GitHub Desktop.
Save britg/1616386 to your computer and use it in GitHub Desktop.
Bonus strike CSS
$('#bar').removeClass('new').addClass('activated');
#bar {
width: 600px;
height: 60px;
position: relative;
background-color: rgba(153, 153, 153, 0.3);
border-right: solid 5px white;
-moz-transition-property: left;
-webkit-transition-property: left;
-o-transition-property: left;
transition-property: left;
-moz-transition-duration: 1.5s;
-webkit-transition-duration: 1.5s;
-o-transition-duration: 1.5s;
transition-duration: 1.5s;
}
#bar.new {
left: 0;
}
#bar.activated {
left: 600px;
}
$('#bar').bind(CSS3_TRANSITION_END, function () {
//... do stuff
});
$('#bar')css({ left: $('#bar').css('left') });
// Adapted from the Modernizer source code
var transEndEventNames = {
'WebkitTransition' : 'webkitTransitionEnd',
'MozTransition' : 'transitionend',
'OTransition' : 'oTransitionEnd',
'msTransition' : 'msTransitionEnd', // maybe?
'transition' : 'transitionEnd'
},
CSS3_TRANSITION_END = transEndEventNames[ Modernizr.prefixed('transition') ];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment