我设置了一个滑块,这样每次单击下一个按钮时,图像都会从不同的方向滑入。例如; 第一次单击从顶部滑动第二次从左上到第三从左上等等等
到目前为止,我的前三个工作正常,但在第四次单击之后,图像只能从侧面滑入。
这是我到目前为止所拥有的
<script type="text/javascript">
var totalslides = '6';
var slidenum = 0;
var slidenext = 0;
var slideType = '';
$(function(){
$('#gallery-next').data('counter',1);
$('#gallery-next').click(function() {
slidenum = parseInt($('#gallery-next').data('counter'));
slidenext = slidenum+1
slideType = $('#'+slidenum+'-slide').attr('class')
slideType = slideType.split('-')[0]
if (slideType =='') slideType='up';
else slideType = 'right';
//alert('Next slideType is: ' + slideType)
//hide(slide) is a jQueryUI function, so ensure you include that lib
$('#'+slidenext+'-slide').delay(605).show('slide',{direction:slideType}, 1000);
$('#'+slidenum+'-slide').fadeOut(600);
$('#'+slidenext+'-text').delay(731).fadeIn(1000);
$('#'+slidenum+'-text').fadeOut(600);
slidenum = slidenum % totalslides + 1;
$('#gallery-next').data('counter',slidenum);
console.log(slideType);
});
});
</script>
<div id="slider">
<section class="horizontal-gallery">
<img src="images/waikanae/crafar_h1.jpg" class="" id="1-slide"/>
<p id="1-text" class="horizontal-gallery-text">This is the first image in the gallery </p>
</section>
<section class="vertical-gallery">
<img src="images/waikanae/crafar_v1.jpg" class="picture2 init-hidden" id="2-slide"/>
<p id="2-text" class="vertical-gallery-text init-hidden">This is the second image in the gallery, it should be sliding down</p>
</section>
<section class="horizontal-gallery">
<img src="images/waikanae/crafar_h1.jpg" class="picture3 init-hidden" id="3-slide"/>
<p id="3-text" class="horizontal-gallery-text text-3 init-hidden">This is the third image in the gallery it should be sliding in from the side </p>
</section>
<section class="vertical-gallery">
<img src="images/waikanae/crafar_v1.jpg" class="picture4 init-hidden" id="4-slide"/>
<p id="4-text" class="vertical-gallery-text text-4 init-hidden">This is the fourth image in the gallery, it should be sliding down </p>
</section>
http://luvly.co.nz/space/test/waikanae-beach-house.html
如果有人能弄清楚为什么它不能正常工作,将不胜感激!干杯