2011-12-01 72 views
1

我正在使用Ariel Flesler的serialScroll脚本,并想将类添加到活动或突出显示的项目,以便我可以使用CSS进行设计。阅读the documentation我发现通知触发器,但我不知道如何/如果它可以用来实现这一点。jQuery SerialScroll:将类添加到活动项目

这是我的代码:

jQuery的

jQuery(function($){ 

    $('#slideshow').serialScroll({ 
     items:'li', 
     prev:'#screen2 a.prev', 
     next:'#screen2 a.next', 
     offset:-180, 
     start: 0, 
     duration:1200, 
     force:true, 
     stop:true, 
     lock:false, 
     cycle:false, 
     jump: true 
    }); 

}); 

HTML

<div id="screen2"> 
    <div id="buttons"> 
     <a class="prev" href="#">Previous</a> 
     <a class="next" href="#">Next</a> 
     <br class="clear" /> 
    </div> 
    <div id="slideshow"> 
     <ul> 
      <li><img src="http://www.stockvault.net/data/s/113497.jpg" /></li> 
      <li><img src="http://www.stockvault.net/data/s/100177.jpg" /></li> 
      <li><img src="http://www.stockvault.net/data/s/101916.jpg" /></li> 
      <li><img src="http://www.dreamstime.com/animal-steps-in-snow-thumb12853223.jpg" /></li> 
      <li><img src="http://www.dreamstime.com/animal-eggs-thumb15876342.jpg" /></li> 
      <li><img src="http://www.dreamstime.com/animal-cat-thumb15385101.jpg" /></li> 
      <li><img src="http://www.dreamstime.com/green-nature-thumb596309.jpg" /></li> 
      <li><img src="http://www.dreamstime.com/office-in-nature-thumb3256171.jpg" /></li> 
      <li><img src="http://www.dreamstime.com/nature-tree-thumb16030502.jpg" /></li> 
      <li><img src="http://www.dreamstime.com/gift-of-the-nature-thumb15977958.jpg" /></li> 
      <li><img src="http://www.dreamstime.com/nature-abstract-thumb3615419.jpg" /></li> 
      <li><img src="http://www.dreamstime.com/nature-path-in-forest-with-sunshine-thumb8241130.jpg" /></li> 
      <li><img src="http://www.dreamstime.com/nature-walk-thumb8436665.jpg" /></li> 
      <li><img src="http://www.dreamstime.com/save-the-nature-thumb15696583.jpg" /></li> 
     </ul> 
    </div> 
</div> 

我误解了通知触发的功能?如果是这样,是否有任何替代方法来完成我所追求的目标?

+0

我会看看onBefore函数 - 从文档: 在每次滚动之前调用一个函数。它接收以下参数:事件对象,目标元素,要滚动的元素,项目集合以及集合中目标元素的位置。 范围(this)将指向获取该事件的元素。如果该函数返回false,则该事件将被忽略。 –

回答

3

从插件示例页面,这里是如何被使用onBefore:

onBefore:function(e, elem, $pane, $items, pos){ 
    /** 
    * 'this' is the triggered element 
    * e is the event object 
    * elem is the element we'll be scrolling to 
    * $pane is the element being scrolled 
    * $items is the items collection at this moment 
    * pos is the position of elem in the collection 
    * if it returns false, the event will be ignored 
    */ 
    //those arguments with a $ are jqueryfied, elem isn't. 
} 
在功能

,您可以将您的活动类,并使用onAfter功能从先前元素删除类。