Horizontal slide list jQuery -
i have following html markup
<ul class="banner"> <li class="current" id="0"><img src="images/first.png"/></li> <li id="1"><img src="images/second.png" /></li> <li id="2"><img src="images/third.png" /></li> </ul>
i want first item slide out & replaced second item & on. end item 'loop round' first item. math logic simple.
the first item slides out list 'collapses' 0 height , second <li>
not replace it.
here's have in jquery:
// globals $currentbannerimage; // before page created $(document).delegate("#indexpage", "pagebeforecreate", function() { // non current banner images $noncurrentbannerlistitems = $("ul.banner li").not(".current"); // hide them if ($noncurrentbannerlistitems.size() > 0) { $noncurrentbannerlistitems.each(function() { $(this).hide(); } $currentbannerimage = 0; } }); }); // when page has loaded & been inserted dom $(document).delegate("#indexpage", "pagebeforecreate", function() { // prevent default image dragging behavior on desktops $("img").on("dragstart",function(dragevent) { dragevent.preventdefault(); }); $("ul.banner li").swipeleft(function() { // swiped element id // current element $currentelementid = $currentbannerimage; $newelementid = $currentelementid+1; // slide touched element left $('#'+currentelementid).hide("slide", {direction: "left"},1000); $('#'+$newelementid).show("slide",{direction: "right"},1000); }); });
Comments
Post a Comment