2013-05-18 148 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

謝謝你,完美的工作。 –

相關問題