2

I tried to do

myfun(params,
   function(){
       //something happen
   }
);

but it is not working, and I absolutely do not know why, and I am going crazy. I am still banging my head on a problem after several weeks, and I need really an help because I am not so good at Jquery syntax.

What I am trying to achieve is: Starting a function that check if you are hovering inside a circle area, if you do than trigger a sequence of function, one after another (in this case showing a series of animation). And I cannot make "one after another".

I am trying to do this, because in safari when you make a link round with radius-border, and you want to hover on the element, it still behave as a square. And I would like not to use image-maps.

As well I cannot re-use the same function to check the hovering inside a circle area more than once (do not ask me why, I tried to understand but I am not clever enough or able enough to comprehend), so my only last resource it is to try to trigger an event based on a sequence.

aniCircle it is the function where I want to nest my sequences of animations. This it is how does it look the function:

$("#cv").hover( 
    function(){
        $("#sliders .circle").css("z-index","6");

        aniCircle(1, $(this), "#slider1", {"opacity":"0"},{"opacity":"1"}, 0, speed2, 
            function(){$("#slider2").delay(speed2).animate({"opacity":"1"},speed2)}
        );

    },
    function(){

        $("#slider1").animate({"opacity":"0"},speed2)
        $("#slider2").delay(speed2).animate({"opacity":"0"},speed2)

    }
);

Here there is the webpage http://life-is-simple.co.uk/test5/index.html

Remember on FF4 it works fine the circle area, it is on webkit browser that it doesn't and I want to fix it using JS.

Thank you for all your help

Littlemad
  • 700
  • 1
  • 7
  • 19
  • It's Javascript syntax. Javascript is the language, jQuery is the library. – Lightness Races in Orbit Mar 27 '11 at 14:18
  • yes, but jquery needs to be written in a specific way, for this reason I wrote syntax, if you tell me that you cannot use a phrase of this kind I will modify my content. – Littlemad Mar 27 '11 at 14:30
  • No more than Javascript does. That's why it's called Javascript syntax. The syntax used with jQuery is not unique to jQuery. – Lightness Races in Orbit Mar 28 '11 at 00:05
  • Could you isolate the exact effect you're looking for? Like a webpage that has *only* the elements you mean to affect? That would make answering the question much easier. – wlangstroth Apr 15 '11 at 13:28
  • It is what I need to do, I realised as well that I wasn't helpful with my request. Unluckily I do not have time today (I am working on some extra projects, and I cannot take care of my website at the moment, for this reason I disappeares), and I have to remake the question once again when I will create a bettere example. Sorry for the time consuming experience :( – Littlemad Apr 17 '11 at 11:44

5 Answers5

2

I think using jquery .queue() can resolve your problem.

gnarf
  • 105,192
  • 25
  • 127
  • 161
pmaruszczyk
  • 2,157
  • 2
  • 24
  • 49
  • I would tend to agree - http://stackoverflow.com/questions/1058158/can-somebody-explain-jquery-queue-to-me might be useful for more documentation... – gnarf Apr 17 '11 at 09:13
0

jQuery animate() takes a "complete" callback. You can nest the sequence like:

$("#slider1").animate(
    {"opacity":"0",
     "speed": speed2,
     "complete": second_animation
    }
 );

function second_animation() {
 $("#slider2").animate()...
}

The slider2 animation will not begin until the slider1 animation is complete.

Liza Daly
  • 2,933
  • 23
  • 31
  • My function aniCircle is not a an animation, it contains animation after various checks, and the callback (I guess) it is not working. Please have a look at the code of that function – Littlemad Mar 28 '11 at 15:03
0

It looks like you are trying something like:

var outer = function(){
var  test = function(){
    alert('fired 1');
}()
var  test2 = function(){
    alert('fired 2');
}()
}

Notice the '()' after the method declaration which makes it fire immediately. These will fire one after the other, but if you apply code to them that will fire asynchronously, then you will need to use a callback method.

ChrisThompson
  • 1,998
  • 12
  • 17
0

JavaScript does not have "function sequences" by default. jQuery's animate() can handle callback functions because it's coded to call the callback function when the animation is complete.

I think you're looking for something like:

function setupThenCall(param1, param2, fn) {
    // do some setup / processing

    // call callback function after setup
    fn();
}

If you're doing something more complicated, e.g. multiple levels of callbacks, you may want to use jQuery's queue().

Jeffery To
  • 11,836
  • 1
  • 27
  • 42
0

I am sorry but I have to remake the question later on in the future, I noticed that without a more straightforward example, and without having time to dedicate to my website (I found myself fairly busy on various projects all week long and even after normal working hours), I do not want to keep my question open just for the sake of keeping open without trying and testing your solutions suggested.

I am sorry for the losing time that I have made you spent on this question. I'll try to be better organised in the future. Thank you very much for your time.

I tried to closed it, but couse of the bounty I cannot close it :(

Littlemad
  • 700
  • 1
  • 7
  • 19
  • this is bad form. You gave a bounty for your question. People tried to help you, perhaps partly due to the bounty. Of course you shouldn't be closing it off. You should encourage further answers, and award the bounty to the one you like best, or allow the system to allocate 1/2 of your bounty automatically to the answer with the highest votes. – Stephen Chung Apr 18 '11 at 08:42
  • I agree, I do not like have chosen this solution. I personally do not care about the points, I can always recuperate later on. The problem it is the time that I do not have to follow and test the suggestion of everyone. How do I contact an admin and ask him for help? I do not mind repart my points to the people, or vote up their answers, or at least keep open this much longer, I am really snowed down with work, but I do not like vote an answer without being sure that the answer was the right one (I do not want to create a wrong content precedent for a question) – Littlemad Apr 19 '11 at 15:49
  • in that case, just leave it and let the system award the bounty to the answer with the higher upvotes. – Stephen Chung Apr 20 '11 at 02:59