PDA

View Full Version : Flying Butterfly script - please vanish on my signal



courthate
09-26-2007, 02:20 PM
1) Script Title: Flying Butterfly script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/butterfly.htm

3) Describe problem: Hey, it's me again ... the one with the black butterflies flying over his band's website. You've helped me a lot on this topic:
http://www.dynamicdrive.com/forums/showthread.php?t=24163

Now it turned out to be a problem to use the Butterfly script in combination with the Lightbox (http://www.huddletogether.com/projects/lightbox/) (by Lokesh Dhakar) because it slows the performance down a lot. A friend of mine had a lack of 55% on his performance of his P4 Dualcore :eek: just by visiting the website and browsing through the pictures using the lightbox-script.

My question would be:
Is there a way to make the butterflies disappear (like clicking them) when the lightbox gets activated? They come back anyway by opening another subcontent on the website due to "reloading" it so there's no need for an extra point like "reactivate them when the lightbox gets closed".

All the scripts I use on the website (http://www.worldofnosotros.de/) are located here (http://www.worldofnosotros.de/css/).

It would be great if you can help me again with this kind of problem :)

Greetings from Germany
Chriss

ddadmin
09-27-2007, 05:32 AM
A better way may just be to dismiss the butterflies altogether after x seconds, or when the user clicks on certain links on the page etc. You can do this by first adding the below function to the script:


function hidebutterflies(){
if (typeof startfly!="undefined")
clearInterval(startfly)
for(i=0; i<floatimages.length; i++)
document.getElementById("pic"+i).style.visibility='hidden'
}

So to dismiss the butterflies after 5 seconds, for example, you would call the function as so:


setTimeout("hidebutterflies()", 2000)

courthate
09-27-2007, 03:12 PM
... or when the user clicks on certain links on the page etc. You can do this by first adding the below function to the script:
I tried this one, but the butterflies were still roaming around when I hit the lightbox-links :-/

First I added your code right behind the "hidebutterflies"-function - no effect; then I replaced to existing function with your code - still no effect. What did I do wrong?

Your idea to hide the butterflies by clicking any link on the website sounds good so far.

ddadmin
09-28-2007, 07:38 AM
How are you currently calling the function I posted above to disable the butterfly effect onclick? It should look something like:


function hidebutterflies(){
if (typeof startfly!="undefined")
clearInterval(startfly)
for(i=0; i<floatimages.length; i++)
document.getElementById("pic"+i).style.visibility='hidden'
}

document.onclick=function(){
hidebutterflies()
}

courthate
09-28-2007, 02:05 PM
My code had no function like this one:



document.onclick=function(){
hidebutterflies()
}

I used to original code from your website. That's why I posted to URL for the current directory of my script-files at the end of my first post ;)

What I was talking about was this one:


function hidebutterfly(){
for(i=0; i<floatimages.length; i++){
if (IE4)
eval("document.all.pic"+i+".style.visibility='hidden'")
else if (NS6)
document.getElementById("pic"+i).style.visibility='hidden'
else if (NS4)
eval("document.pic"+i+".visibility='hide'")
clearInterval(startfly)
}
}

as your idea also started with "hidbutterfly()".

Now the butterflies vanish by clicking anywhere on the website. That's OK, but I have to admit that I no close to nothing about JavaScript, so please excuse this question:

Is it possible to limit the hide-function to the fact that the user has to click on a link instead of vanishing for a click anywhere on the website?

ddadmin
09-28-2007, 10:26 PM
Ah I didn't realize the script came with a "hidebutterfly()" function already. That's how long I've not worked on this script. :) Well, either will do fyi.

It's certainly possible to attach this function so it's only called when someone clicks on a link on the page. The problem is I don't believe this will work fully in your case, as what may appear as links in the Lightbox interface either aren't or are dynamically generated I believe, so clicking on them will not dismiss the butterfly effect

courthate
09-29-2007, 05:43 PM
The problem is I don't believe this will work fully in your case, as what may appear as links in the Lightbox interface either aren't or are dynamically generated I believe, so clicking on them will not dismiss the butterfly effect
OK.

As I said, the new script also works fine for me. Thanks a lot.

Greetings
Chriss from Germany