images is not an array use Ox.forEach

This commit is contained in:
j 2011-04-23 00:46:37 +02:00
parent 498b17926f
commit 09e97fa08b

View file

@ -18,14 +18,14 @@ Ox.Flipbook = function(options, self) {
timestamp = $('<div>').css({ timestamp = $('<div>').css({
'position': 'absolute', 'position': 'absolute',
'text-align': 'center', 'text-align': 'center',
'width': '100%', 'width': '100%'
}) })
.hide(), .hide(),
that = new Ox.Element('div', self) that = new Ox.Element('div', self)
.defaults({ .defaults({
frames: {}, frames: {},
duration: 0, duration: 0,
icon: '', icon: ''
}) })
.options(options || {}) .options(options || {})
.append(icon) .append(icon)
@ -66,9 +66,10 @@ Ox.Flipbook = function(options, self) {
function getFrame(position) { function getFrame(position) {
var frame; var frame;
frames.forEach(function(img, i) { Ox.forEach(frames, function(img, i) {
if (!frame || i <= position) if (!frame || i <= position) {
frame = img; frame = img;
}
}); });
return frame; return frame;
} }
@ -78,7 +79,7 @@ Ox.Flipbook = function(options, self) {
frames[i] = new Image(); frames[i] = new Image();
frames[i].onload = function() { frames[i].onload = function() {
frameHeight = frames[i].height / frames[i].width * that.width(); frameHeight = frames[i].height / frames[i].width * that.width();
} };
frames[i].src = src; frames[i].src = src;
}); });
} }
@ -89,10 +90,11 @@ Ox.Flipbook = function(options, self) {
} else if (key == 'icon') { } else if (key == 'icon') {
icon.attr('src', value); icon.attr('src', value);
} }
} };
if(options.icon) if(options.icon) {
icon.attr('src', options.icon); icon.attr('src', options.icon);
}
cacheFrames(); cacheFrames();
return that; return that;
}; };