Welcome Guest!

If you do not have an account yet on The Web Squeeze forums, please Register! It’s FREE and there are many benefits:

  • Receive Fast Advice
  • Learn Programming Languages
  • Get Professional Website Reviews
  • Quick Troubleshooting Assistance

> Delay Actions?

This is a discussion on Delay Actions?, within the Javascript section. This forum and the thread "Delay Actions?" are both part of the Programming Your Website category.

 
Reply to this topicStart new topic
> Delay Actions?
Jason
post May 5 2008, 04:47 AM
Post #1


Master of the Universe
******

Group: Mentor
Posts: 1,094
Joined: 15-February 08
From: London, England
Member No.: 141



I thought I had a cool little js app going on. What happens is that you can cycle through a couple of images when you press some buttons. During testing today I got a little bored and decided to try to press all of the buttons at once. I managed to press 2 and 2 images loaded at the same time. This should be allowed to happen.

What are my options on setting some sort of delay between buttons being pressed?

Here is my rather simple code.

CODE
$(document).ready(function(){
        
        $("#item2").hide();
        $("#item3").hide();
        $("#item4").hide();
        $("#item5").hide();
        
        
        $("#1").click(function () {            
            $("#item1").show("slow");
            $("#item2").hide();
            $("#item3").hide();
            $("#item4").hide();
            $("#item5").hide();
        });
        $("#2").click(function () {
            $("#item2").show("slow");
            $("#item1").hide();
            $("#item3").hide();
            $("#item4").hide();
            $("#item5").hide();
        });
        $("#3").click(function () {
            $("#item3").show("slow");
            $("#item2").hide();
            $("#item1").hide();
            $("#item4").hide();
            $("#item5").hide();
        });
        $("#4").click(function () {
            $("#item4").show("slow");
            $("#item2").hide();
            $("#item3").hide();
            $("#item1").hide();
            $("#item5").hide();
        });
        $("#5").click(function () {
            $("#item5").show("slow");
            $("#item2").hide();
            $("#item3").hide();
            $("#item4").hide();
            $("#item1").hide();
        });
        
    });


--------------------
Go to the top of the page
 
+Quote Post
Rakuli
post May 6 2008, 07:30 AM
Post #2


Squeeze Machine
*****

Group: Team Leaders
Posts: 568
Joined: 13-February 08
From: Catching the squeezed drips downunder.
Member No.: 13



Umm.. This is jQuery right? I don't use frameworks often but I do like jQuery and it looks familiar...

Have you tried assigning to the onmouseup event handler instead? Click requires a full down and up which is a touch slower than just triggering when the mouse button is lifted.

I can't really tell you much more without seeing it in context of your page.


--------------------
Bright Idea? -- Don't Let it disappear
Go to the top of the page
 
+Quote Post
MikeHopley
post May 6 2008, 08:30 AM
Post #3


Squeeze Machine
*****

Group: Mentor
Posts: 505
Joined: 15-February 08
From: UK
Member No.: 143



You could run a timer.

It always felt hacky to me, but it should work.
Go to the top of the page
 
+Quote Post
Jason
post May 6 2008, 08:39 AM
Post #4


Master of the Universe
******

Group: Mentor
Posts: 1,094
Joined: 15-February 08
From: London, England
Member No.: 141



I found a simpler solution this morning. I just sped up the speed of the effect. Still looks good, fixes bug.


--------------------
Go to the top of the page
 
+Quote Post
If you found The Web Squeeze to be helpful, please donate so we can keep this site FREE, FRESH, and fortified with Web Design & Development info!
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No New Posts   3 velo 108 15th June 2008 - 09:13 AM
Last post by: Jason