Skip to content

Commit

Permalink
fixed bug with transition on firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
claudia-romano committed Jun 8, 2014
1 parent 6ed2c8c commit b282aab
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions js/main.js
@@ -1,20 +1,38 @@
jQuery(document).ready(function($){
var is_firefox = navigator.userAgent.indexOf('Firefox') > -1;

//open team-member bio
$('#cd-team').find('ul a').on('click', function(event){
event.preventDefault();
var selected_member = $(this).data('type');
$('main').addClass('slide-out');
$('.cd-member-bio.'+selected_member+'').addClass('slide-in');
$('.cd-member-bio-close').addClass('is-visible');
$('body').addClass('overflow-hidden');

// firefox transitions break when parent overflow is changed, so we need to wait for the end of the trasition to give the body an overflow hidden
if( is_firefox ) {
$('main').addClass('slide-out').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){
$('body').addClass('overflow-hidden');
});
} else {
$('main').addClass('slide-out');
$('body').addClass('overflow-hidden');
}

});

//close team-member bio
$(document).on('click', '.cd-overlay, .cd-member-bio-close', function(event){
event.preventDefault();
$('main').removeClass('slide-out');
$('.cd-member-bio').removeClass('slide-in');
$('.cd-member-bio-close').removeClass('is-visible');
$('body').removeClass('overflow-hidden');

if( is_firefox ) {
$('main').removeClass('slide-out').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){
$('body').removeClass('overflow-hidden');
});
} else {
$('main').removeClass('slide-out');
$('body').removeClass('overflow-hidden');
}
});
});

0 comments on commit b282aab

Please sign in to comment.