jCarousel in Modal Windows in Chrome
Hi, first i want to thank you for this plugin, but sadly i ran into a problem. Im loading a carousel through ajax in modal window and everything is as it should be except the navigation buttons. In Chrome they are disabled and i can't find where. In every other browser i tried, the nav buttons works fine.
To summarize:
Chrome,Safari: navigation buttons are disabled, removing the style mark up does nothing, they just doesn't work IE,FF,Opera: navigation buttons are working correctly
Hard to say without actually seeing some code. I'm guessing your carousel is hidden when you call .jcarousel() on it. If your modal script supports some kind of callback when it becomes visible, you could try to reload jCarousel with $('youselector').jcarousel('reload');.
Yep, the code is problematic and has been removed in the 0.3 branch. Though some users have reported that their setup didn't worked after removing it. The workaround is to call $.jcarousel.windowLoaded() before intializing your carousel:
<script>
$.jcarousel.windowLoaded();
$('#mycarousel').jcarousel();
</script>
Did you tried what i suggested in my first answer?
You could try the current dev version from https://github.com/jsor/jcarousel/blob/0.2/lib/jquery.jcarousel.js
So I was still having this problem with the latest -dev release of 0.2. In a nutshell, I am loading content in a modal (drupal + ctools modal) and saw Chrome not showing buttons. I tracked down why it was happening. In short, two things were responsible: dimension and clipping. They were coming back with different figures for Chrome and Safari, which made Chrome think there were 5 visible images on screen when there really were 4.
There are three things I did to fix this. I did not find these written up anywhere else so I'll add them here.
-
Added this patch, which ensures that later versions of Chrome and Safari use the correct initialization code. In this case, it's just that one line change.
-
In my own CSS, I manually set the following class: .mypage .jcarousel-skin-default .jcarousel-clip { width: XYZpx; }
This fixed the clipping problem, where the this.clip[0].offsetWidth was being calculated incorrectly in Chrome. It was off by 100px, and I have no idea why. But overriding the CSS class manually as indicated above makes it calculate correctly.
- This one took the longest to figure out, but dimension was calculated incorrectly. I attempted to specify my own dimension by using itemFallbackDimension, however that isn't used if the dimension can be calculated. In my case it COULD be calculated, it was just calculating them differently again for Chrome and Safari. This one was off by 10px but it was enough to cause Chrome to think 5 images were onscreen instead of 4. My 'fix' is really a hack to use itemFallbackDimension first and calculated values second. Here's what it looks like. Again all I did was swap it so that this.options.itemFallbackDimension is used first.
dimension: function(e, d) {
var el = $(e);
if (d == null) {
return !this.options.vertical ?
(($jc.intval(this.options.itemFallbackDimension) ||
el.innerWidth() +
$jc.intval(el.css('margin-left')) +
$jc.intval(el.css('margin-right')) +
$jc.intval(el.css('border-left-width')) +
$jc.intval(el.css('border-right-width')))) :
(($jc.intval(this.options.itemFallbackDimension) ||
el.innerHeight() +
$jc.intval(el.css('margin-top')) +
$jc.intval(el.css('margin-bottom')) +
$jc.intval(el.css('border-top-width')) +
$jc.intval(el.css('border-bottom-width'))));
} else {
var w = !this.options.vertical ?
d - $jc.intval(el.css('marginLeft')) - $jc.intval(el.css('marginRight')) :
d - $jc.intval(el.css('marginTop')) - $jc.intval(el.css('marginBottom'));
$(el).css(this.wh, w + 'px');
return this.dimension(el);
}
},
... and finally I specified the correct value for itemFallbackDimension.
Now it all works across all browsers.
It can be triggered after you've called jcarousel too: jQuery(window).trigger("load.jcarousel");