$(function() { //remove js-disabled class $("#viewer").removeClass("js-disabled"); //create new container for images $("
").attr("id", "title").text(title).appendTo("div#controls") : $("p#title").text(title) ; }); //restart on mouseout $("a.wrapper").live("mouseout", function(e) { //hide controls if not hovering on them (e.relatedTarget == null) ? null : (e.relatedTarget.id != "controls") ? $("div#controls").slideUp("slow").remove() : null ; //work out total travel distance var totalDistance = parseInt($("div#container").width()) + parseInt($("div#viewer").width()); //work out distance left to travel var distanceLeft = ($("div#container").hasClass("ltr")) ? totalDistance - (parseInt($("div#container").css("left")) + parseInt($("div#container").width())) : totalDistance - (parseInt($("div#viewer").width()) - (parseInt($("div#container").css("left")))) ; //new duration is distance left / speed) var newDuration = distanceLeft / speed; //restart anim animator($("div#container"), newDuration, $("div#container").attr("class")); }); //handler for ltr button $("#ltr").live("click", function() { //stop anim $("div#container").stop(true); //swap class names $("div#container").removeClass("rtl").addClass("ltr"); //work out total travel distance var totalDistance = parseInt($("div#container").width()) + parseInt($("div#viewer").width()); //work out remaining distance var distanceLeft = totalDistance - (parseInt($("div#container").css("left")) + parseInt($("div#container").width())); //new duration is distance left / speed) var newDuration = distanceLeft / speed; //restart anim animator($("div#container"), newDuration, "ltr"); }); //handler for rtl button $("#rtl").live("click", function() { //stop anim $("div#container").stop(true); //swap class names $("div#container").removeClass("ltr").addClass("rtl"); //work out total travel distance var totalDistance = parseInt($("div#container").width()) + parseInt($("div#viewer").width()); //work out remaining distance var distanceLeft = totalDistance - (parseInt($("div#viewer").width()) - (parseInt($("div#container").css("left")))); //new duration is distance left / speed) var newDuration = distanceLeft / speed; //restart anim animator($("div#container"), newDuration, "rtl"); }); });