-->

与“caroufredsel” jQuery的旋转木马响应问题(Responsiveness iss

2019-09-18 08:31发布

我已经建立了使用一个优秀的响应旋转木马caroufredsel和项目应始终滚动一次一个,并与流畅的动画。

目前,在页面加载(或刷新)的项目(每次一个)正确地滚动,但经过重新调整大小的浏览器窗口,按下下次启动跳过2个或多个项目。 如果再刷新它解决了这个问题,直到屏幕宽度的下一个变化。

此外,当屏幕处于最小可能宽度的动画唯一的工作(每次1个项目可见),当2个或更多的项目在同一时间看到它永远不会奏效。

现场可以看到这里 。

目前,下列代码触发插件(我确信,当它被破坏,屏幕调整大小后重新设置有是把它扔全部关闭一些挥之不去的注入CSS或等同,只是不能针下来。 ..):

<script type="text/javascript">

$(document).ready(function() {

$("#guitars-gallery").carouFredSel({
auto: false,
circular: false,
prev: '#prev',
next: '#next',
responsive : true,
height : 'auto',
scroll: 1,
items : { width : 370, visible : { min : 1, max : 3 } } }); 

});

function doSomething() {

$('#guitars-gallery').trigger('destroy', true);
$('#guitars-gallery').css({'text-align': '','float': '','position': '','top': '','right': '','bottom': '','left': '','width': '90%','height': '','margin': '1% auto'});

$("#guitars-gallery").carouFredSel({
auto: false,
circular: false,
prev: '#prev',
next: '#next',
responsive : true,
height : 'auto',
scroll: 1,
items : { width : 370, visible : { min : 1, max : 3 } } });

};

var resizeTimer;

$(window).resize(function() {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(doSomething, 100);
});
</script>

任何帮助将:-)不胜感激

Answer 1:

我没有测试代码,但尝试。 你说得对注入的CSS。 转盘被用新的内联样式再包裹,但以前的包装不除,使得新包装一个以前的“囚徒”。

function sliderInit() {
("#guitars-gallery").carouFredSel({
    auto: false,
    circular: false,
    prev: '#prev',
    next: '#next',
    responsive : true,
    height : 'auto',
    scroll: 1,
    items : { 
        width : 370, 
        visible : { 
            min : 1, 
            max : 3 
        } 
    } 
}); 
};

$(window).load(function() {
sliderInit();
}); 

var resizeTimer;

$(window).resize(function() {
$('.caroufredsel_wrapper').removeAttr('style');
$('#guitars-gallery').removeAttr('style');
clearTimeout(resizeTimer);
resizeTimer = setTimeout(sliderReInit, 100);
});


文章来源: Responsiveness issue with 'caroufredsel' jquery carousel