Skip to main content

Forums

This topic contains 4 replies, has 2 voices, and was last updated by  Shikkediel 8 months, 1 week ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #278409

    odc
    Participant

    I want to write a function call that checks a variable and updates the DOM on my page by increasing this heart size.

    How do I increase this heart size with jquery?

    https://jsfiddle.net/5dn1L6s8/1/
    thanks

    #278450

    Shikkediel
    Participant

    The animation will override the transform if it’s on the same element. You could target a parent element instead.

    codepen.io/anon/pen/KrKbvr

    #278482

    odc
    Participant

    thanks. could you help me with this problem ive been having as well. how do I make the gold heart move faster? with this if statement ive written preferably https://codepen.io/anon/pen/KrwaQq

    #278483

    Shikkediel
    Participant

    I think something like this?

    function animateDiv(myclass) {
    
      var newq = makeNewPosition();
    
      if (myclass == '.heart.gold') {
        $(myclass).animate({ top: newq[0], left: newq[1] }, 1000, 'linear', function() {
          animateDiv(myclass);
        });
      }
      else {
        $(myclass).animate({ top: newq[0], left: newq[1] }, movingSpeed, 'linear', function() {
          animateDiv(myclass);
        });
      }
    }
    
    #278487

    Shikkediel
    Participant

    I’ve optimised the script a bit:

    codepen.io/anon/pen/bQdoWm

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

icon-link icon-logo-star icon-search icon-star