Next, we need a function that we can execute each time an animation ends. Add the following code beneath the code we added previously:
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 the 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 to be done repeatedly; so, it is more efficient to bundle them up into a single function instead of defining them separately within...