I am experimenting with a page transition and use bind () to check if the css event transition completed. After each class is added, the transition occurs and is deleted upon completion, which is known when the code is run in the bind () call, but only one callback call works. Therefore, the transition is incomplete.
Jquery
$("a").click(function () {
var effect = 'slide';
var options = {
direction: $('.mySelect').val()
};
var duration = 500;
var $sel = $('div.active');
if ($(this).attr('class') === 'Contact') {
$sel.addClass('active1');
var $element = $('.active1').bind("webkitAnimationEnd oAnimationEnd msAnimationEnd animationend", function (event) {
if (event.animationName === "three") {
console.log('the event happened');
}
$sel.removeClass('active');
$sel.removeClass('active1');
$('#Container4').addClass('active');
$('#Container4').addClass('active2');
});
var $element1 = $('.active2').bind("webkitAnimationEnd oAnimationEnd msAnimationEnd animationend", function (event) {
alert("da1");
$(this).removeClass('active2');
});
}
if ($(this).attr('class') === 'About') {
$sel.addClass('active1');
var $element = $('.active1').bind("webkitAnimationEnd oAnimationEnd msAnimationEnd animationend", function (event) {
if (event.animationName === "three") {
console.log('the event happened');
}
$sel.removeClass('active');
$sel.removeClass('active1');
$('#Container3').addClass('active');
$('#Container3').addClass('active2');
});
var $element1 = $('.active2').bind("webkitAnimationEnd oAnimationEnd msAnimationEnd animationend", function (event) {
$(this).removeClass('active2');
});
}
if ($(this).attr('class') === 'Services') {
$sel.addClass('active1');
var $element = $('.active1').bind("webkitAnimationEnd oAnimationEnd msAnimationEnd animationend", function (event) {
if (event.animationName === "three") {
console.log('the event happened');
}
$sel.removeClass('active');
$sel.removeClass('active1');
$('#Container2').addClass('active');
});
$('#Container2').addClass('active');
$('#Container2').addClass('active2');
var $element1 = $('.active2').bind("webkitAnimationEnd oAnimationEnd msAnimationEnd animationend", function (event) {
$(this).removeClass('active2');
});
}
if ($(this).attr('class') === 'Home') {
$sel.addClass('active1');
var $element = $('.active1').bind("webkitAnimationEnd oAnimationEnd msAnimationEnd animationend", function (event) {
if (event.animationName === "three") {
console.log('the event happened');
}
$sel.removeClass('active');
$sel.removeClass('active1');
$('#Container1').addClass('active');
});
$('#Container1').addClass('active');
$('#Container1').addClass('active2');
var $element1 = $('.active2').bind("webkitAnimationEnd oAnimationEnd msAnimationEnd animationend", function (event) {
$(this).removeClass('active2');
});
$('#Container1').toggle(effect, 'right', '10');
}
});
Want a solution without using a third-party plug-in and explain why this discrepancy occurs in detail
Decision
source
share