2012-01-10 43 views
2

我试图调整,或破坏和调整窗口大小时重新应用jCarouselLite插件调整jCarouselLite,但我没有成功,这是因为我创建了一个网站,每个页面都是一个“礼”其中,通过菜单进行滚动到页面“......再涂或调整窗口大小

我已经tryied使用这种在调整大小,并重新应用jcarousellite导航时,但它并没有工作:

$('#mega').jCarouselLite = null; 

这是我使用的代码,但如果我继续重新应用jcarouselLite,旋转木马去疯狂!

$(document).ready(function(){ 
    w = $(window).width(); 
    h = $(window).height(); 
    $('#mega li').css('width',w); 
    $('#mega li').css('height',h); 
    $('#mega').jCarouselLite({ 
     circular:false, 
     vertical:true, 
     speed:1000, 
     visible:1, 
     btnGo:["#home", "#comofunciona", "#porquemegafome", "#contato"] 
    }); 
}); 
$(window).resize(function() { 
    w = $(window).width(); 
    h = $(window).height(); 
    $('#mega li').css('width',w); 
    $('#mega li').css('height',h); 
    $('#mega').jCarouselLite({ 
     circular:false, 
     vertical:true, 
     speed:1000, 
     visible:1, 
     btnGo:["#home", "#comofunciona", "#porquemegafome", "#contato"] 
    }); 
}); 

SOLUTION:

“idrumgood”,我想只能用“礼”来做到这一点,但搜索更多一些关于停用插件,我发现我不得不取消绑定的点击也因此,这里是代码,我不得不申请:

$(window).resize(function() { 
    $('#mega').jCarouselLite = null; 
    $('#home, #comofunciona, #porquemegafome, #contato').unbind('click'); //buttons I defined on btnGo option 
    runCarousel(); //again 
    aClick(); // function where I get the li index and save into a hidden input, on resize it keeps li position! :) 
}); 

回答

1

jCarouselLite(和几乎所有的旋转木马插件)注入时创建传送带一些额外的标记。通常,它被设置用的elementsWidth * numberOfElements与隐藏在溢出的宽度的容纳元件。其中还包含第二个包含元素,这就是实际移动的内容。然后,你的元件然后浮动和次级包含元素的左边距被改变以得到滚动效果。

点即,如果要改变,则需要改变那些包含div和/或当调整窗口大小您正在滚动通过元素的宽度的宽度。

尝试改变窗口上这些元素的尺寸调整,而不是重新初始化旋转木马,看看会发生什么情况(不包括您的标记,那是关于我能给的最好的建议)

+0

感谢反正idrumgood,我发现了一个可能解决方案,但现在还有另一个问题... – 2012-01-10 17:14:37