Next we need a function that we can execute each time an animation ends:
function postAnim(dir) { var keyMatch = parseInt(key.match(/\d+$/)); (parseInt(slide.css("left")) < 0) ? prev.show() : prev.hide(); (parseInt(slide.css("left")) === -1600) ? next.hide() : next.show(); if (dir) { var titleKey = (dir === "back") ? keyMatch - 1 : keyMatch + 1; key = "image" + titleKey; } container.find("#title").text(details[key].title); container.find(".active").removeClass("active"); container.find("a[href=#" + key + "]").addClass("active"); };
In this second section of code, we define a function that we'll call after an animation ends. This is used for some housekeeping to do various things that may need doing repeatedly, so it is more efficient to bundle them up into a single function instead of defining them separately within event handlers. This is the postAnim()
function and it may accept a single...