1
固定!不能相信我之前沒有看到:JQuery Cycle插件隨機播放
$('#s4')
.before('<div id="nav">')
.cycle({
fx: 'shuffle',
speed: 500,
shuffle: { top:15, left: 300 },
timeout: 0,
pager: '#nav',
cleartypeNoBg:true
});
你可以在這裏選擇shuffle動畫。我有我的設置爲最高:15和左:300
我試圖使用週期插件,但我需要它來洗牌到右邊而不是左邊。我已經改變
opts.shuffle = opts.shuffle || {left:-w, top:15};
成功地做到這
opts.shuffle = opts.shuffle || {left:+w, top:15};
唯一的問題是,我洗牌圖像是安靜寬敞,創建圖像之間的過渡期間,水平滾動條。這在洗牌時不會發生,我不知道我錯過了什麼。以下是洗牌效果的片段。任何幫助表示讚賞!
// shuffle
$.fn.cycle.transitions.shuffle = function($cont, $slides, opts) {
var i, w = $cont.css('overflow', 'visible').width();
$slides.css({left: 0, top: 0});
opts.before.push(function(curr,next,opts) {
$.fn.cycle.commonReset(curr,next,opts,true,true,true);
});
// only adjust speed once!
if (!opts.speedAdjusted) {
opts.speed = opts.speed/2; // shuffle has 2 transitions
opts.speedAdjusted = true;
}
opts.random = 0;
opts.shuffle = opts.shuffle || {left:+w, top:15};
opts.els = [];
for (i=0; i < $slides.length; i++)
opts.els.push($slides[i]);
for (i=0; i < opts.currSlide; i++)
opts.els.push(opts.els.shift());
// custom transition fn (hat tip to Benjamin Sterling for this bit of sweetness!)
opts.fxFn = function(curr, next, opts, cb, fwd) {
var $el = fwd ? $(curr) : $(next);
$(next).css(opts.cssBefore);
var count = opts.slideCount;
$el.animate(opts.shuffle, opts.speedIn, opts.easeIn, function() {
var hops = $.fn.cycle.hopsFromLast(opts, fwd);
for (var k=0; k < hops; k++)
fwd ? opts.els.push(opts.els.shift()) : opts.els.unshift(opts.els.pop());
if (fwd) {
for (var i=0, len=opts.els.length; i < len; i++)
$(opts.els[i]).css('z-index', len-i+count);
}
else {
var z = $(curr).css('z-index');
$el.css('z-index', parseInt(z)+1+count);
}
$el.animate({left:0, top:0}, opts.speedOut, opts.easeOut, function() {
$(fwd ? this : curr).hide();
if (cb) cb();
});
});
};
opts.cssBefore = { display: 'block', opacity: 1, top: 0, left: 0 };
};
HTML
<div id="contentAreaJS" class="contentArea">
<div id="s4" class="pics">
<div id="navlist">
<ul>
<li id="mon"><a href="http://image.iloqal.com/lib/fe5c1570746107757c1c/m/1/ChilisLightbox_fajitas.png" style="text-decoration:none;" rel="shadowbox;width=500;height=400;"></a></li>
<li id="tue"><a href="http://image.iloqal.com/lib/fe5c1570746107757c1c/m/1/ChilisLightbox_tacos.png" style="text-decoration:none;" rel="shadowbox;width=500;height=400;"></a></li>
<li id="wed"><a href="http://image.iloqal.com/lib/fe5c1570746107757c1c/m/1/ChilisLightbox_chips.png" style="text-decoration:none;" rel="shadowbox;width=500;height=400;"></a></li>
<li id="thur"><a href="http://image.iloqal.com/lib/fe5c1570746107757c1c/m/1/ChilisLightbox_dessert.png" style="text-decoration:none;" rel="shadowbox;width=500;height=400;"></a></li>
<li id="fri"><a href="http://image.iloqal.com/lib/fe5c1570746107757c1c/m/1/ChilisLightbox_burger.png" style="text-decoration:none;" rel="shadowbox;width=500;height=400;"></a></li>
</ul>
</div>
<a href="https://www.chilistogo.com/Pages/Welcome.aspx" target="_blank"><img src="http://image.iloqal.com/lib/fe5c1570746107757c1c/m/1/ChilispartyPlatters.png" height="237" width="769" /></a>
<a href="http://www.chilis.com/EN/HappyHours/001.005.0609.pdf" target="_blank"><img src="http://image.iloqal.com/lib/fe5c1570746107757c1c/m/1/ChilishappyHour.png" height="237" width="769" /></a>
</div>
</div>
它可能是之前/之後的鉤子。我試圖改變溢出,圖像看起來像是消失在隱形牆後面。 – Dandy 2012-01-09 23:44:07