-1

Hello want to make a image with a heartbeat effect. 2 quick pulses and then 2 seconds break, 2 quick pulses and then 2 seconds break. I want to put it in a div, if possible to centralize the scaling anchor...

Here is what I have now:

(function pulse(back) {
    $('#seventyfive img').animate(
        {
            width: (back) ? $('#seventyfive img').width() + 20 : $('#seventyfive img').width() - 20            
        }
    , 700);
    $('#seventyfive').animate(
        {          
            'font-size': (back) ? '100px' : '140px',
            opacity: (back) ? 1 : 0.5
        }
    , 700, function(){pulse(!back)});
})(false);

Or you can check this JSFiddle

bogatyrjov
  • 5,317
  • 9
  • 37
  • 61
Valerxx22
  • 774
  • 1
  • 11
  • 32
  • 1
    **... and the question title** – gdoron Sep 16 '13 at 07:36
  • 2
    Improve it in what way? What you want instead? – Shadow The GPT Wizard Sep 16 '13 at 07:37
  • @enhzflep really? so you think that bad questions can't be improved? See [this question](http://stackoverflow.com/q/18510656/447356) - it started with **seven downvotes** and after I helped the OP improve it, it's now +19 score and bunch of upvoted answers. Please don't tell me about undermining SO's good quality. – Shadow The GPT Wizard Sep 16 '13 at 07:44
  • Yes, really. No, that's not what I said or think for a minute - of course bad questions can be improved - you'd be a fool to think otherwise. As you may or may not be alluding to - it's the down-votes that often sharpen a question asker's effort at communication. I'll thank you not to misrepresent what I've said. (If indeed you are) Supporting such a poor question will undermine my confidence in anything I ever see you write in the future. The question you linked to is infinitely better than this one - even if lazy and not displaying any research effort. – enhzflep Sep 16 '13 at 07:53
  • I think I need more coffee, because I have not the foggiest idea what you two are fighting about. If indeed you are. – Mr Lister Sep 16 '13 at 08:11
  • Guys, do you really read the description, or just the title? – Valerxx22 Sep 16 '13 at 08:42

1 Answers1

6

Something like this :

(function pulse(back, i) {
    var el = $('#seventyfive img'),
        wd = back    ? 20 : -20,
        op = back    ? 1  : 0.5,
        de = i%4!==0 ? 0  : 1400;

    el.delay(de).animate({
        width   : el.width() + (wd), opacity : op
    }, 300, function() {
        pulse(!back, ++i);
    });
})(false, 0);

FIDDLE

adeneo
  • 312,895
  • 29
  • 395
  • 388