PDA

View Full Version : Help with a mouse trail script



itivae
02-03-2012, 11:27 PM
1) Script Title: Circling text trail

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex13/circletext.htm

3) Describe problem:

It isnt really a problem just need some help or advice. I am a rookie at Javascript. What I am trying to accomplish is to use this script but only after an onClick (as in I want the effect but only after someone clicks an href or button). Can anyone help me to make this happen? At line 128 it has an (onload, init) is there a way to point this to an onClick. Any help is appreciated.


Thanks in advance.

jscheuer1
02-04-2012, 01:40 AM
At the end of the script:


if (window.addEventListener){
window.addEventListener('load', init, false);
document.addEventListener('mouseover', mouse, false);
document.addEventListener('mousemove', mouse, false);
if (/Apple/.test(navigator.vendor))
window.addEventListener('scroll', ascroll, false);
}
else if (window.attachEvent){
window.attachEvent('onload', init);
document.attachEvent('onmousemove', mouse);
};

})();

Make it like so:


if (window.addEventListener){
//window.addEventListener('load', init, false);
document.addEventListener('mouseover', mouse, false);
document.addEventListener('mousemove', mouse, false);
if (/Apple/.test(navigator.vendor)) // Safari only
window.addEventListener('scroll', ascroll, false);
}
else if (window.attachEvent){
//window.attachEvent('onload', init);
document.attachEvent('onmousemove', mouse);
};
window.initcircletext = init;
})();

Now it won't start onload and you may have a link to click to start the effect like so:


<a href="#" onclick="initcircletext(); initcircletext = function(){}; return false;">Start It</a>

In fact, you can have as many of these as you like. However, only the first one clicked will do anything.

The text:


Start It

in the above may be replaced with any text of your choosing. You could even substitute an img tag there.

itivae
02-04-2012, 02:36 PM
Thank You. I will give that a try.