2013-05-18 77 views
0

我正在使用cycle.all.js jQuery插件(http://jquery.malsup.com/cycle/)。现在它工作正常,但我需要第一个图像比其他所有图像有更短的暂停时间。因此,当用户第一次悬停他鼠标移到幻灯片-DIV周期立即开始,但第一张幻灯片后,它改变了超时650这是我的代码看起来像现在:jQuery cycle.all.js第一张幻灯片暂停

$('div#slideshow').mouseenter(-> 
    $(this).cycle 
    fx: "fade", 
    speed: 1 
    timeout: 650 
).mouseleave -> 
    $(this).cycle 'stop' 
+0

只是说明你的CS。 '@'映射到'this'。 –

回答

1

你可以做这与delay选项,并给它一个负值:

$(this).cycle 
    fx: "fade", 
    speed: 1 
    timeout: 650 
    delay: -650 
) 

注意,这使得它马上去到第二张幻灯片,我认为这是你想要的,因为幻灯片的第一形象在用户悬停在它之前已经可见。

正如本雅明指出的那样,在CoffeeScript中可以使用@作为快捷方式this

$('div#slideshow').mouseenter(-> 
    $(@).cycle 
    fx: "fade", 
    speed: 1, 
    timeout: 650, 
    delay: -650 //go to the next slide immediately 
).mouseleave -> 
    $(@).cycle 'stop' 
+0

谢谢你,完美的工作。 –

相关问题