1
我正在使用這個滑塊,所有的工程很好,但爲什麼在小屏幕 (小於480)或響應視圖它不運行?! 我該如何解決這個問題?滑塊溢出響應
在小提琴的更多細節如下
http://jsfiddle.net/roXon/tMxp5/1/
$(function() {
var c = 1,
timeOut,
fit,
isStopped = false,
boxw = $('.box').outerWidth(true),
boxh = $('.box').outerHeight(true),
boxn = $('.box').length;
$('#slider').width(boxw*boxn);
$('#gal, #slider').height(boxh);
//////////////////////////////////
function measure() {
var winw = $(window).width();
fit = Math.ceil(winw/boxw)-1; // math ceil -1 to get the number of COMPLETELY visible boxes
$('#gal').width(winw);
$('#t').html('Boxw='+boxw+' Boxh='+boxh+' Winw='+winw+' VisibleBoxes='+ fit);
}
measure();
$(window).resize(function() {
measure();
});
//////////////////////////////////
function b(){
cc = (c === 1) ? $('.prev').hide() : $('.prev').show();
ccc =(c >= boxn/fit) ? $('.next').hide() : $('.next').show();
}
$('.btn').hide();
/////////////////////////////////
function a(cb){
$('#slider').animate({left: '-'+ (boxw*fit)*(c-1) },800, cb);
}
////////////////////////////////
function auto() {
if(isStopped){ return };
clearTimeout(timeOut);
timeOut = setTimeout(function() {
$('.btn').hide();
c++;
if (c >= (boxn/fit)+1) {
c = 1;
}
a(function(){
auto();
});
}, 2000);
}
auto();
/////////////////////////////////////////////////////////////////
$('.next').click(function() {
c++;
b();
a();
});
$('.prev').click(function() {
c--;
b();
a();
});
/////////////////////////////////////////////////////////////////
$('#gal').bind('mouseenter mouseleave', function(e) {
(e.type === 'mouseenter') ?
(isStopped=true, b(), clearTimeout(timeOut)) :
(isStopped=false, auto());
});
});
謝謝
它的工作!非常感謝!!! –
沒問題,很高興我可以幫忙! – Pete
另一個問題......在這種情況下,一個單獨的div的寬度是350像素但是如果每個div都有不同的寬度,我怎麼能在每個div開始時停止幻燈片? –