Monday 15 September 2014

javascript - How to create Google's +1 rolling animation using JS? -


When you click the +1 button underneath a post on Google+, the counter on the right pay increase, but this one Rolling animation, like a slightly older odometer:

see rolling animation on the right

How can I create such an effect using Javascript?

OK, I provided a solution, in fact I'm adding a new number below the first one Animate them both The first number is being removed Set the second number in the correct position.

  $ (function () {$ (document) .on ('click', 'button', function (evt) {var num, element, auto = $ ("number.") First (); num = parseInt ($ ("number: last"). Text ()) num = num + 1; element = '& lt; div class = "number" & gt;' + num.toString () + '& Lt; / div & gt;' $ (". Container"). Attachment (element); $ (". Number"). Animate ({top: "- = 20"}, 150, function ( ) {Self-remove (); $ ("number.") CSS ("top", "0 pixels");});});});   

this is the solution

No comments:

Post a Comment