整个网站是由JS / JQ控制的单个HTML5“页面”。我有几个幻灯片,需要能够从一个幻灯片移动到另一个,而不使用“上一个”按钮将每个“imageStack”返回到它的起始点。具体来说,我需要创建一个将所有“imageStack”重置为初始状态的函数。我正在使用Greensock补间一些值。这是我的JS:
$("#imageStack1 img:gt(0)").hide();
$("#nextArrowProduct1").click(function() {
currentPic = currentPic + 1;
if (currentPic <=4) {
$("#imageStack1 :first-child").fadeOut().next().fadeIn().end().appendTo("#imageStack1");
hideProductBlurbs();
TweenMax.to("#productBlurb1-"+currentPic, 0.7, {"top":"875px", "visibility":"visible", "opacity":"0.85", ease:Power4.easeOut});
}
if (currentPic >4) {
currentPic = 4;
};
});
$("#previousArrowProduct1").click(function() {
currentPic = currentPic -1;
if (currentPic >=1) {
$("#imageStack1 img:first-child").fadeOut();
$("#imageStack1 img:last-child").prependTo("#imageStack1").fadeOut();
$("#imageStack1 img:first-child").fadeIn();
TweenMax.to("#productBlurb1-"+currentPic, 0.7, {"top":"875px", "opacity":"0.85", ease:Power4.easeOut});
hideProductBlurbs();
TweenMax.to("#productBlurb1-"+currentPic, 0.7, {"top":"875px", "visibility":"visible", "opacity":"0.85", ease:Power4.easeOut});
}
if (currentPic <1) {
currentPic = 1};
});