Hi folks, I'm having some difficulty with a script which uses
Mootools. I have taken over this script from someone else, so I'm not
entirely sure how it works and what it uses, but as far as I can see
it is a straightforward use of Mootools (as far as I can tell, it's
version 1.2.0 - I don't particularly want to change the version, as I
don't know what else might be using it).
I'm using this to expand an image when it is hovered over. The idea
is that the transition is a 'tween', with the image height going from
45px to 65px.
The javascript code is (this is applied to each image):
function(el,index){
// Set up transition
var tween = new Fx.Tween(el);
el.style.height = '45px';
// Attach event handlers
el.addEvents(
{
'mouseenter' : function() {
el.tween('height', [45, 65]);
},
'mouseleave' : function() {
el.tween('height', [65, 45]);
}
}
);
}
When I mouseover, nothing happens. I put in some alerts, and as far
as i can tell, it's getting to the .mouseenter' function ok, but then
failing when 'start' gets called for the tween. The particular line
in mootools.js that it seems to fail on is
var B=Array.flatten(arguments);
The arguments array at this point is [["height", [65, 45]]].
On digging in further, it seems to be this section that's the problem:
flatten: function() {
return this.inject([], function(array, value) {
return array.concat(Object.isArray(value) ?
value.flatten() : [value]);
});
}
I don't really understand what this is doing, so not sure how to fix
it. It may be that the problem is earlier than this, and that the
value in arguments is, by this stage, invalid, and that's causing it
to bail out.
Can anyone help? Thank you all very much.
I can supply more code if it's needed.