zainstalowałem na swojej stronie skrypt jCarousel. Skrypt działa poprawnie na wszystkich przeglądarkach oprócz Mozilli Firefox tam przy próbie wejścia na stronę wyskakuje błąd:
Cytat
jCarousel: No width/height set for items. This will cause an infinite loop. Aborting...
W czym może tkwić problem?
Podejrzewam, że to coś z plikiem jquery.jcarousel.js, ale z kodowaniem w JS jest u mnie cieńko więc nie wiem co jest przyczyną problemu.
Myślę, że to może mieć związek z tym fragmentem kodu:
Kod
/**
* Prepares the carousel and return the position for a certian index.
*
* @name pos
* @type Number
* @param Number i The index of the element to scoll to.
* @cat Plugins/jCarousel
*/
pos: function(i) {
if (this.locked || this.animating)
return;
if (this.options.wrap != 'circular')
i = i < 1 ? 1 : (this.options.size && i > this.options.size ? this.options.size : i);
var back = this.first > i;
var pos = $jc.intval(this.list.css(this.lt));
// Create placeholders, new list width/height
// and new list position
var f = this.options.wrap != 'circular' && this.first <= 1 ? 1 : this.first;
var c = back ? this.get(f) : this.get(this.last);
var j = back ? f : f - 1;
var e = null, l = 0, p = false, d = 0;
while (back ? --j >= i : ++j < i) {
e = this.get(j);
p = !e.length;
if (e.length == 0) {
e = this.create(j).addClass(this.className('jcarousel-item-placeholder'));
c[back ? 'before' : 'after' ](e);
}
c = e;
d = this.dimension(e);
if (p)
l += d;
if (this.first != null && (this.options.wrap == 'circular' || (j >= 1 && (this.options.size == null || j <= this.options.size))))
pos = back ? pos + d : pos - d;
}
// Calculate visible items
var clipping = this.clipping();
var cache = [];
var visible = 0, j = i, v = 0;
var c = this.get(i - 1);
while (++visible) {
e = this.get(j);
p = !e.length;
if (e.length == 0) {
e = this.create(j).addClass(this.className('jcarousel-item-placeholder'));
// This should only happen on a next scroll
c.length == 0 ? this.list.prepend(e) : c[back ? 'before' : 'after' ](e);
}
c = e;
var d = this.dimension(e);
if (d == 0) {
alert('jCarousel: No width/height set for items. This will cause an infinite loop. Aborting...');
return 0;
}
if (this.options.wrap != 'circular' && this.options.size !== null && j > this.options.size)
cache.push(e);
else if (p)
l += d;
v += d;
if (v >= clipping)
break;
j++;
}
// Remove out-of-range placeholders
for (var x = 0; x < cache.length; x++)
cache[x].remove();
// Resize list
if (l > 0) {
this.list.css(this.wh, this.dimension(this.list) + l + 'px');
if (back) {
pos -= l;
this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) - l + 'px');
}
}
// Calculate first and last item
var last = i + visible - 1;
if (this.options.wrap != 'circular' && this.options.size && last > this.options.size)
last = this.options.size;
if (j > last) {
visible = 0, j = last, v = 0;
while (++visible) {
var e = this.get(j--);
if (!e.length)
break;
v += this.dimension(e);
if (v >= clipping)
break;
}
}
var first = last - visible + 1;
if (this.options.wrap != 'circular' && first < 1)
first = 1;
if (this.inTail && back) {
pos += this.tail;
this.inTail = false;
}
this.tail = null;
if (this.options.wrap != 'circular' && last == this.options.size && (last - visible + 1) >= 1) {
var m = $jc.margin(this.get(last), !this.options.vertical ? 'marginRight' : 'marginBottom');
if ((v - m) > clipping)
this.tail = v - clipping - m;
}
// Adjust position
while (i-- > first)
pos += this.dimension(this.get(i));
// Save visible item range
this.prevFirst = this.first;
this.prevLast = this.last;
this.first = first;
this.last = last;
return pos;
},
* Prepares the carousel and return the position for a certian index.
*
* @name pos
* @type Number
* @param Number i The index of the element to scoll to.
* @cat Plugins/jCarousel
*/
pos: function(i) {
if (this.locked || this.animating)
return;
if (this.options.wrap != 'circular')
i = i < 1 ? 1 : (this.options.size && i > this.options.size ? this.options.size : i);
var back = this.first > i;
var pos = $jc.intval(this.list.css(this.lt));
// Create placeholders, new list width/height
// and new list position
var f = this.options.wrap != 'circular' && this.first <= 1 ? 1 : this.first;
var c = back ? this.get(f) : this.get(this.last);
var j = back ? f : f - 1;
var e = null, l = 0, p = false, d = 0;
while (back ? --j >= i : ++j < i) {
e = this.get(j);
p = !e.length;
if (e.length == 0) {
e = this.create(j).addClass(this.className('jcarousel-item-placeholder'));
c[back ? 'before' : 'after' ](e);
}
c = e;
d = this.dimension(e);
if (p)
l += d;
if (this.first != null && (this.options.wrap == 'circular' || (j >= 1 && (this.options.size == null || j <= this.options.size))))
pos = back ? pos + d : pos - d;
}
// Calculate visible items
var clipping = this.clipping();
var cache = [];
var visible = 0, j = i, v = 0;
var c = this.get(i - 1);
while (++visible) {
e = this.get(j);
p = !e.length;
if (e.length == 0) {
e = this.create(j).addClass(this.className('jcarousel-item-placeholder'));
// This should only happen on a next scroll
c.length == 0 ? this.list.prepend(e) : c[back ? 'before' : 'after' ](e);
}
c = e;
var d = this.dimension(e);
if (d == 0) {
alert('jCarousel: No width/height set for items. This will cause an infinite loop. Aborting...');
return 0;
}
if (this.options.wrap != 'circular' && this.options.size !== null && j > this.options.size)
cache.push(e);
else if (p)
l += d;
v += d;
if (v >= clipping)
break;
j++;
}
// Remove out-of-range placeholders
for (var x = 0; x < cache.length; x++)
cache[x].remove();
// Resize list
if (l > 0) {
this.list.css(this.wh, this.dimension(this.list) + l + 'px');
if (back) {
pos -= l;
this.list.css(this.lt, $jc.intval(this.list.css(this.lt)) - l + 'px');
}
}
// Calculate first and last item
var last = i + visible - 1;
if (this.options.wrap != 'circular' && this.options.size && last > this.options.size)
last = this.options.size;
if (j > last) {
visible = 0, j = last, v = 0;
while (++visible) {
var e = this.get(j--);
if (!e.length)
break;
v += this.dimension(e);
if (v >= clipping)
break;
}
}
var first = last - visible + 1;
if (this.options.wrap != 'circular' && first < 1)
first = 1;
if (this.inTail && back) {
pos += this.tail;
this.inTail = false;
}
this.tail = null;
if (this.options.wrap != 'circular' && last == this.options.size && (last - visible + 1) >= 1) {
var m = $jc.margin(this.get(last), !this.options.vertical ? 'marginRight' : 'marginBottom');
if ((v - m) > clipping)
this.tail = v - clipping - m;
}
// Adjust position
while (i-- > first)
pos += this.dimension(this.get(i));
// Save visible item range
this.prevFirst = this.first;
this.prevLast = this.last;
this.first = first;
this.last = last;
return pos;
},