简体   繁体   English

jquery循环插件 - 操作next / prev按钮?

[英]jquery cycle plugin - manipulate next/prev buttons?

I created a standart jquery slideshow from the jquery cycle plugin , which i didnt change. 我从jquery 循环插件创建了一个标准的jquery幻灯片,我没有改变。 Now everything works just fine after I followed this tutorial. 我遵循教程后现在一切正常。 My Question now is, does anyone know how to change the plugins code, that the prev and next buttons are not both shown on mouseOver, but just one of them depending in which half of the slideshow the mouse is? 我的问题现在是,有没有人知道如何更改插件代码,prev和下一个按钮都不会同时显示在mouseOver上,但只有其中一个取决于鼠标滑板的哪一半?

I would be really pleased if someone can help me :) 如果有人可以帮助我,我会很高兴:)

Update. 更新。 I wasn't happy with my last update as it worked but could have been a little cleaner. 我对上次更新感到不满意,因为它有效,但本来可以更干净一些。

JSFiddle: 的jsfiddle:

http://jsfiddle.net/lucuma/fg6d4/10/ http://jsfiddle.net/lucuma/fg6d4/10/

$(document).ready(function() {
$('#sliders').hover(
function() {

    $('.controller', this).fadeIn();
}, function() {
    $('.controller', this).fadeOut();
});

$('#slideshow').cycle({
    prev: $('.controller .prev', this),
    next: $('.controller .next', this),
    after: function(currSlideElement, nextSlideElement, options, forwardFlag) {
        // you can easily adapt this to hide prev on firstslide and next on last slide
        if (options.currSlide < options.slideCount / 2) {
            $(options.prev).hide();
            $(options.next).show();
        } else {
            $(options.prev).show();
            $(options.next).hide();
        }

    }

});

});​​ });

HTML: HTML:

<div id="sliders">

    <div id="slideshow">

      <div><img src="http://weblogs.marylandweather.com/4526619322_1912218db8.jpg" /></div>
      <div><img src="http://www.silverstar-academy.com/Blog/wp-content/uploads/2012/03/03-14-12N00184967.jpg" /></div>
      <div><img src="http://cdn.the2012scenario.com/wp-content/uploads/2011/11/sunspot-500x500.jpg" /></div>
   </div>
    <div class="controller">
      <a href="#" class="prev">prev</a>
      <a href="#" class="next">next</a>
    </div>
</div>
​

CSS: CSS:

#sliders{width:500px;height:500px;position:relative}
#slideshow {width:100%;height:100%;}
#sliders .controller {display:none;position:absolute;top:50px;z-index:100;width:100%;height:20px}
#sliders .controller a {background-color:white;padding:10px;color:red}
#sliders .controller a.next {position:absolute;right:0}

I think you're going to have to add two elements layered on top of the image and add a toggle on roll over. 我认为你将不得不在图像顶部添加两个元素,并在翻转时添加一个切换。 Cycle doesn't toggle or position the buttons automatically. 循环不会自动切换或定位按钮。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM