I have created a set() of Raphaeljs elements called ‘nav’. I am trying to change the attr() of said elements on mousemove, but for some reason the set() comes back with Array length 0…
There is a JSFiddle available here:
http://jsfiddle.net/neuroflux/g8wHa/1/
And this is a snippet of the loop and function:
function init() {
sketch = Raphael(10, 10, 800, 600);
nav = sketch.set();
runNavigation();
document.addEventListener('mousemove',checkMouse);
};
function runNavigation() {
for (var a = 0; a < 5; a++) {
navButton = sketch.rect(navX + (a*105), 10, 100, 100, 32, 32).attr({
stroke:'#666',
fill:'#dedede'
}).click(function(){
alert(0);
});
nav.push = navButton;
}
};
function checkMouse(e) {
mX = e.pageX;
mY = e.pageY;
/* This section is broken... */
/* It says the Array's length is 0 */
console.log('x: '+mX);
console.log('y: '+mY);
console.log('Element: ');
console.log(nav);
nav.attr({
y:mX/2,
x:mY/2
});
/*****************************/
};
Thanks in advance!
You must’ve meant
nav.push(navButton)inrunNavigation