user1393215
user1393215

Reputation:

setInterval being firing right away instead of waiting for event.

Instead of setInterval happening once konami fires, it starts as soon as the page loads.

Konami is a jquery plugin that lets you use the konami code as an event.

I know it works otherwise, a simple alert() works fine.

    <script type="text/javascript">


        $(document).ready(function(){
            $(window).konami(setInterval(function(){

            var one = Math.random()/1.2;
            var two = Math.random()/1.5;
            var three = Math.random()/2;


            $("#fire1").animate({
                opacity: one
                }, { duration: 100, queue: false });
            $("#fire2").animate({
                opacity: two
            }, { duration: 100, queue: false });
            $("#fire3").animate({
                opacity: three
            }, { duration: 100});

            }, 100));
        });
    </script>

Upvotes: 1

Views: 143

Answers (1)

user1393215
user1393215

Reputation:

Figured it out just as I was about to post.

It was very similar to this: .on event firing on load instead of click

Once I wrapped it in function(){ }, it waited for the konami code.

Upvotes: 1

Related Questions