{"id":3693,"date":"2015-04-02T17:41:35","date_gmt":"2015-04-02T09:41:35","guid":{"rendered":"https:\/\/sdeno.com\/?p=3693"},"modified":"2016-09-18T12:08:05","modified_gmt":"2016-09-18T04:08:05","slug":"jquery-animatenumber%e6%95%b0%e5%ad%97%e5%8a%a8%e7%94%bb%e6%8f%92%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/sdeno.com\/?p=3693","title":{"rendered":"jquery-animateNumber\u6570\u5b57\u52a8\u753b\u63d2\u4ef6"},"content":{"rendered":"<p><a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2015\/04\/num_aniamte.zip\">\u4e0b\u8f7d\uff1anum_aniamte<\/a><\/p>\n<p>\u6570\u5b57\u8fc7\u6e21 \u6570\u5b57\u52a8\u753b \u6570\u5b57 animate \u6570\u5b57\u9012\u589e \u6570\u5b57\u9012\u52a0<\/p>\n<p>\u6570\u5b57\u7684\u8fc7\u5ea6\u6548\u679c\u517c\u5bb9IE7+<\/p>\n<p>\u53e6\u5916\u9644\u52a0jquery.color.min.js\u989c\u8272\u8fc7\u6e21\u4ee5\u53ca\u5b57\u4f53\u8fc7\u6e21\u6548\u679c<\/p>\n<p>\u6240\u6709\u6848\u4f8b\uff1a<a href=\"http:\/\/aishek.github.io\/jquery-animateNumber\/\" target=\"_blank\">http:\/\/aishek.github.io\/jquery-animateNumber\/<\/a><\/p>\n<p>\u5b9e\u4f8b\u4e00\u3001\u57fa\u7840\u52a8\u753b<\/p>\n<pre>\/\/html\u4ee3\u7801\uff0c\u4e0b\u9762\u4f8b\u5b50\u76f8\u540c\u3002\r\n&lt;p&gt;This plugin only &lt;span id=\"lines\"&gt;0&lt;\/span&gt; lines of code.&lt;\/p&gt;\r\n\/\/JS \u4ee3\u7801\uff0c\u8bf7\u628a\u4ee3\u7801\u653e\u5165script\u6807\u7b7e\u5185\uff0c\u4e0b\u9762\u4f8b\u5b50\u76f8\u540c\r\n$('#lines').animateNumber({ number: 165 });\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>\u5b9e\u4f8b\u4e8c\u3001\u6570\u5b57\u95f4\u663e\u793a\u5206\u9694\u7b26<\/p>\n<pre>&lt;p&gt;World population is &lt;span id=\"world-population\"&gt;0&lt;\/span&gt;.&lt;\/p&gt;\r\nvar comma_separator_number_step = $.animateNumber.numberStepFactories.separator(',')\r\n$('#world-population').animateNumber(\r\n  {\r\n    number: 7095217980,\r\n    numberStep: comma_separator_number_step\r\n  }\r\n);\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>\u5b9e\u4f8b\u4e09\u3001\u4f7f\u7528\u591a\u4e2a\u5c5e\u6027\u63a7\u5236\u52a8\u753b<\/p>\n<pre>&lt;p&gt;Fun level &lt;span id=\"fun-level\" style=\"color: red;\"&gt;0 %&lt;\/span&gt;.&lt;\/p&gt;\r\nvar percent_number_step = $.animateNumber.numberStepFactories.append(' %')\r\n$('#fun-level').animateNumber(\r\n {\r\n number: 100,\r\n color: 'green',\r\n 'font-size': '30px',\r\n easing: 'easeInQuad',\r\n numberStep: percent_number_step\r\n },\r\n 15000\r\n);<\/pre>\n<p>&nbsp;<\/p>\n<p>\u5b9e\u4f8b\u56db\u3001\u81ea\u5b9a\u4e49\u6570\u5b57\u6b65\u9636\u5904\u7406\u65b9\u6cd5\uff08\u53e5\u67c4\uff09<\/p>\n<pre>$('#points').animateNumber(\r\n {\r\n   number: 72,\r\n   numberStep: function(now, tween) {\r\n   var target = $(tween.elem);\r\n   target\r\n    .prop('number', now) \/\/ keep current prop value\r\n    .text(now);\r\n   }\r\n }\r\n);<\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #555555;\">\u5b9e\u4f8b\u4e94\u3001\u5b9a\u4e49\u52a8\u753b\u6570\u5b57\u7684\u5f00\u59cb\u6570\u636e\uff0c\u4e0b\u9762\u5b9e\u4f8b\u5b9a\u4e49\u7684\u662f\u4ece10\u5230100\u6570\u636e\u7684\u53d8\u5316<\/span><\/p>\n<pre>&lt;p id=\"ten\"&gt;From ten to hundred.&lt;\/p&gt;\r\n \r\n$('#ten')\r\n   .prop('number', 10)\r\n   .animateNumber(\r\n   {\r\n     number: 100\r\n   },\r\n   20000\r\n);<\/pre>\n<p>&nbsp;<\/p>\n<p>\u5b9e\u4f8b\u516d\u3001\u5e26\u5c0f\u6570\u4f4d<\/p>\n<div class=\"line number1 index0 alt2\" style=\"color: #555555;\"><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">&lt;<\/code><code class=\"html keyword\" style=\"font-weight: bold !important; font-style: normal !important; color: #ff7800 !important;\">p<\/code>\u00a0<code class=\"html color1\" style=\"font-weight: normal !important; font-style: normal !important; color: gray !important;\">id<\/code><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">=<\/code><code class=\"html string\" style=\"font-weight: normal !important; font-style: normal !important; color: blue !important;\">\"decimals\"<\/code><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">&gt;From\u00a0$0,00\u00a0to\u00a0$5,00&lt;\/<\/code><code class=\"html keyword\" style=\"font-weight: bold !important; font-style: normal !important; color: #ff7800 !important;\">p<\/code><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">&gt;<\/code><\/div>\n<div class=\"line number2 index1 alt1\" style=\"color: #555555;\"><\/div>\n<div class=\"line number3 index2 alt2\" style=\"color: #555555;\"><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">\/\/\u00a0\u9700\u8981\u4fdd\u7559\u7684\u5c0f\u6570\u4f4d\u6570<\/code><\/div>\n<div class=\"line number4 index3 alt1\" style=\"color: #555555;\"><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">var\u00a0decimal_places\u00a0=\u00a02;<\/code><\/div>\n<div class=\"line number5 index4 alt2\" style=\"color: #555555;\"><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">var\u00a0decimal_factor\u00a0=\u00a0decimal_places\u00a0===\u00a00\u00a0?\u00a01\u00a0:\u00a0decimal_places\u00a0*\u00a010;<\/code><\/div>\n<div class=\"line number6 index5 alt1\" style=\"color: #555555;\"><\/div>\n<div class=\"line number7 index6 alt2\" style=\"color: #555555;\"><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">$('#decimals')<\/code><\/div>\n<div class=\"line number8 index7 alt1\" style=\"color: #555555;\"><code class=\"html spaces\" style=\"font-weight: normal !important; font-style: normal !important; color: #dd1144;\">\u00a0\u00a0<\/code><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">.animateNumber(<\/code><\/div>\n<div class=\"line number9 index8 alt2\" style=\"color: #555555;\"><code class=\"html spaces\" style=\"font-weight: normal !important; font-style: normal !important; color: #dd1144;\">\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">{<\/code><\/div>\n<div class=\"line number10 index9 alt1\" style=\"color: #555555;\"><code class=\"html spaces\" style=\"font-weight: normal !important; font-style: normal !important; color: #dd1144;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">number:\u00a05\u00a0*\u00a0decimal_factor,<\/code><\/div>\n<div class=\"line number11 index10 alt2\" style=\"color: #555555;\"><\/div>\n<div class=\"line number12 index11 alt1\" style=\"color: #555555;\"><code class=\"html spaces\" style=\"font-weight: normal !important; font-style: normal !important; color: #dd1144;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">numberStep:\u00a0function(now,\u00a0tween)\u00a0{<\/code><\/div>\n<div class=\"line number13 index12 alt2\" style=\"color: #555555;\"><code class=\"html spaces\" style=\"font-weight: normal !important; font-style: normal !important; color: #dd1144;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">var\u00a0floored_number\u00a0=\u00a0Math.floor(now)\u00a0\/\u00a0decimal_factor,<\/code><\/div>\n<div class=\"line number14 index13 alt1\" style=\"color: #555555;\"><code class=\"html spaces\" style=\"font-weight: normal !important; font-style: normal !important; color: #dd1144;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">target\u00a0=\u00a0$(tween.elem);<\/code><\/div>\n<div class=\"line number15 index14 alt2\" style=\"color: #555555;\"><\/div>\n<div class=\"line number16 index15 alt1\" style=\"color: #555555;\"><code class=\"html spaces\" style=\"font-weight: normal !important; font-style: normal !important; color: #dd1144;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">if\u00a0(decimal_places\u00a0&gt;\u00a00)\u00a0{<\/code><\/div>\n<div class=\"line number17 index16 alt2\" style=\"color: #555555;\"><code class=\"html spaces\" style=\"font-weight: normal !important; font-style: normal !important; color: #dd1144;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">\/\/\u00a0force\u00a0decimal\u00a0places\u00a0even\u00a0if\u00a0they\u00a0are\u00a00<\/code><\/div>\n<div class=\"line number18 index17 alt1\" style=\"color: #555555;\"><code class=\"html spaces\" style=\"font-weight: normal !important; font-style: normal !important; color: #dd1144;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">floored_number\u00a0=\u00a0floored_number.toFixed(decimal_places);<\/code><\/div>\n<div class=\"line number19 index18 alt2\" style=\"color: #555555;\"><\/div>\n<div class=\"line number20 index19 alt1\" style=\"color: #555555;\"><code class=\"html spaces\" style=\"font-weight: normal !important; font-style: normal !important; color: #dd1144;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">\/\/\u00a0replace\u00a0'.'\u00a0separator\u00a0with\u00a0','<\/code><\/div>\n<div class=\"line number21 index20 alt2\" style=\"color: #555555;\"><code class=\"html spaces\" style=\"font-weight: normal !important; font-style: normal !important; color: #dd1144;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">floored_number\u00a0=\u00a0floored_number.toString().replace('.',\u00a0',');<\/code><\/div>\n<div class=\"line number22 index21 alt1\" style=\"color: #555555;\"><code class=\"html spaces\" style=\"font-weight: normal !important; font-style: normal !important; color: #dd1144;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">}<\/code><\/div>\n<div class=\"line number23 index22 alt2\" style=\"color: #555555;\"><\/div>\n<div class=\"line number24 index23 alt1\" style=\"color: #555555;\"><code class=\"html spaces\" style=\"font-weight: normal !important; font-style: normal !important; color: #dd1144;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">target.text('$'\u00a0+\u00a0floored_number);<\/code><\/div>\n<div class=\"line number25 index24 alt2\" style=\"color: #555555;\"><code class=\"html spaces\" style=\"font-weight: normal !important; font-style: normal !important; color: #dd1144;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">}<\/code><\/div>\n<div class=\"line number26 index25 alt1\" style=\"color: #555555;\"><code class=\"html spaces\" style=\"font-weight: normal !important; font-style: normal !important; color: #dd1144;\">\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">},<\/code><\/div>\n<div class=\"line number27 index26 alt2\" style=\"color: #555555;\"><code class=\"html spaces\" style=\"font-weight: normal !important; font-style: normal !important; color: #dd1144;\">\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">20000<\/code><\/div>\n<div class=\"line number28 index27 alt1\" style=\"color: #555555;\"><code class=\"html spaces\" style=\"font-weight: normal !important; font-style: normal !important; color: #dd1144;\">\u00a0\u00a0<\/code><code class=\"html plain\" style=\"font-weight: normal !important; font-style: normal !important; color: black !important;\">);<\/code><\/div>\n<div class=\"line number28 index27 alt1\" style=\"color: #555555;\"><\/div>\n<div class=\"line number28 index27 alt1\" style=\"color: #555555;\"><\/div>\n<div class=\"line number28 index27 alt1\" style=\"color: #555555;\"><\/div>\n<div class=\"line number28 index27 alt1\" style=\"color: #555555;\"><\/div>\n<div class=\"line number28 index27 alt1\" style=\"color: #555555;\">\u5b9e\u4f8b\u4e03\u3001\u5012\u8ba1\u65f6\uff0c\u4ee5\u4e0b\u4ee3\u7801\u4e3a\u4ece10\u5012\u6570\u52300<\/div>\n<pre>&lt;p id=\"revese-countdown\"&gt;10&lt;\/p&gt;\r\n \r\n$('#revese-countdown')\r\n   .prop('number', 10)\r\n   .animateNumber(\r\n    {\r\n      number: 0,\r\n      numberStep: function(now, tween) {\r\n      var target = $(tween.elem),\r\n      rounded_now = Math.round(now);\r\n \r\n      target.text(now === tween.end ? 'Launch!' : rounded_now);\r\n      }\r\n   },\r\n   10000,\r\n  'linear'\r\n );<\/pre>\n<p><a href=\"http:\/\/www.jqcool.net\/animate-number.html\" target=\"_blank\">http:\/\/www.jqcool.net\/animate-number.html<\/a><\/p>\n<p><a href=\"http:\/\/www.jq22.com\/jquery-info3030\" target=\"_blank\">http:\/\/www.jq22.com\/jquery-info3030<\/a><\/p>\n<p><a href=\"https:\/\/github.com\/aishek\/jquery-animateNumber\" target=\"_blank\">https:\/\/github.com\/aishek\/jquery-animateNumber<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<p>\u8fd8\u6709\u7b80\u5355\u7684\u65b9\u6cd5\u652f\u6301\u5c0f\u6570\u70b9\uff0c\u8fd8\u53ef\u4ee5\u81ea\u52a8\u8fdb\u884c\u91d1\u94b1\u683c\u5f0f\u5316\uff0c\u8fd8\u6709\u6570\u5b57\u52a8\u753b\u6548\u679c\u3002<\/p>\n<p>\u6548\u679c\uff1a<a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2016\/09\/countTo\/1.html\" target=\"_blank\">https:\/\/sdeno.com\/wp-content\/uploads\/2016\/09\/countTo\/1.html<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u8f7d\uff1anum_aniamte \u6570\u5b57\u8fc7\u6e21 \u6570\u5b57\u52a8\u753b \u6570\u5b57 animate \u6570\u5b57\u9012\u589e \u6570\u5b57\u9012\u52a0 \u6570\u5b57\u7684\u8fc7\u5ea6\u6548\u679c\u517c\u5bb9 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-3693","post","type-post","status-publish","format-standard","hentry","category-11"],"_links":{"self":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/3693","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3693"}],"version-history":[{"count":0,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/3693\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3693"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3693"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3693"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}