GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 一些前端特效 · 2017code/javaScript@907c4eb

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • 数字逐一停止.html
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎数字逐一停止.html‎

Copy file name to clipboard
+72Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Title</title>
6+
</head>
7+
<body>
8+
<div class="num"></div>
9+
</body>
10+
<script src="../javaScript/checkbox/js/jquery-1.9.1.min.js"></script>
11+
<script>
12+
function showScore($ele, num, secand, pause){ //second 按照秒数,动画运行多少秒
13+
if (!secand) { secand = 2;}
14+
if (!pause) { pause = 20;}
15+
16+
var len = String(num).length;
17+
18+
var temnum, times = 0 , stepTimes, max ;
19+
var numArr = String(num).split("");
20+
21+
22+
function getRandom(n){
23+
var num = Math.floor(Math.random()*(Math.pow(10, n)-1 - Math.pow(10, n-1))+Math.pow(10, n-1));
24+
25+
if (String(num).length !== n) {num = getRandom(n);}
26+
27+
return num;
28+
}
29+
30+
function setValue(num, pause, secand){//second 运行多少秒后停止
31+
var len = String(num).length, j=0;
32+
33+
if (!stepTimes) {
34+
max = Math.ceil(secand*1000/len);
35+
stepTimes = Math.ceil(max/pause);
36+
}
37+
38+
temnum = "";
39+
setTimeout(function(){
40+
for (var i = 1; i <= len; i++) {
41+
if (times >= stepTimes*i) {
42+
j++;
43+
temnum += numArr[i-1]+"";
44+
}else{
45+
break;
46+
}
47+
};
48+
49+
if (j < len) {
50+
$ele.html(temnum+""+getRandom(len-j));
51+
}else{
52+
$ele.html(temnum);
53+
}
54+
55+
56+
if (times >= max || j >= len) {return;};
57+
58+
setValue(num, pause, secand);
59+
times++;
60+
61+
}, pause);
62+
63+
64+
}
65+
66+
setValue(num, pause, secand);
67+
68+
}
69+
70+
showScore($(".num"), 2344, 1.5, 10);
71+
</script>
72+
</html>

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.