Results 1 to 7 of 7

Thread: Flying Butterfly script - please vanish on my signal

  1. #1
    Join Date
    Aug 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Flying Butterfly script - please vanish on my signal

    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/s...ad.php?t=24163

    Now it turned out to be a problem to use the Butterfly script in combination with the 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 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 are located here.

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

    Greetings from Germany
    Chriss

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    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:

    Code:
    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:

    Code:
    setTimeout("hidebutterflies()", 2000)

  3. #3
    Join Date
    Aug 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by ddadmin View Post
    ... 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.

  4. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    How are you currently calling the function I posted above to disable the butterfly effect onclick? It should look something like:

    Code:
    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()
    }

  5. #5
    Join Date
    Aug 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    My code had no function like this one:

    Quote Originally Posted by ddadmin View Post
    Code:
    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:

    Code:
    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?

  6. #6
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    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

  7. #7
    Join Date
    Aug 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by ddadmin View Post
    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •