forked from jesucarr/jOdometer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
131 lines (119 loc) · 5.22 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jOdometer jQuery plugin</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="jquery-1.2.6.min.js" type="text/javascript"></script>
<script src="jquery.jodometer.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$('.counter1').jOdometer({increment: 1, counterStart:'000', numbersImage: 'images/jodometer-numbers.png', spaceNumbers: 1, offsetRight:-1});
$('.counter2').jOdometer({increment: 3.17, counterStart:'0087.15', counterEnd:'0159.50', numbersImage: 'images/jodometer-numbers.png', spaceNumbers: 2});
$('.counter3').jOdometer({counterStart:'123', counterEnd:'123', numbersImage: 'images/jodometer-numbers.png'});
$('.counter4').jOdometer({increment: 1, counterStart:'1234567',numbersImage:'images/jodometer-numbers-color.png', formatNumber: true, spaceNumbers: 2, widthDot: 8});
var counter5 = $('.counter5').jOdometer({increment: 1, counterStart:'123',numbersImage:'images/jodometer-numbers-color.png', formatNumber: true, spaceNumbers: 2, widthDot: 8});
var counter6 = $('.counter6').jOdometer({increment: 1, counterStart:'123',numbersImage:'images/jodometer-numbers-color.png', formatNumber: true, spaceNumbers: 2, widthDot: 8});
$("#update-both-button").click(function()
{
counter5.goToNumber($("#input-1").val());
counter6.goToNumber($("#input-2").val());
});
$("#input-1-button").click(function()
{
counter5.goToNumber($("#input-1").val());
});
$("#input-2-button").click(function()
{
counter6.goToNumber($("#input-2").val());
});
});
</script>
<style type="text/css" media="screen">
.counter1{
width:44px;
height:31px;
border:1px solid #000;
overflow:hidden;
position:relative;
background-color:#f00;
}
.counter2{
width:108px;
height:31px;
border:1px solid #000;
overflow:hidden;
position:relative;
background-color:#0f0;
}
.counter3{
width:41px;
height:31px;
border:1px solid #000;
overflow:hidden;
position:relative;
background-color:#0f0;
}
.counter4{
width:135px;
height:31px;
border:5px solid #ccc;
overflow:hidden;
position:relative;
background-color:#ccc;
}
.counter5, .counter6
{
width:41px;
height:31px;
border:1px solid #000;
overflow:hidden;
position:relative;
background-color:#0f0;
}
</style>
</head>
<body>
<h1>jOdometer:</h1>
<pre>
jOdometer is a counter that works like an odometer: moving the numbers up like a wheel
Usually we will need a "position: relative" and an "overflow: hidden" in the container element.
Sample Configuration:
$('.counter').jOdometer({increment: 3.17, counterStart:'0087.15', counterEnd:'0159.50', numbersImage: '/images/numbers.png', spaceNumbers: 2, offsetRight:5});
Config Options:
counterStart: Number we are starting with. To get a specific number of digits/decimals it have to be a string (e.g. '0005.50') // Default: '0000.00'
counterEnd: The counter stop when reach this number. If it is the same as counterStart the odometer is static. False to don't stop never. // Default: false
delayTime: Delay between each number change // Default: 1000
increment: Number increment after each delayTime // Default: 0.01
speed: Speed for the change number animation // Default: 500
easing: Easing for the change number animation. Other than 'swing' or 'linear' must be provided by plugin // Default: 'swing'
numbersImage: Image used for the numbers. You can use .psd provided // Default: '/images/numbers.png'
heightNumber: The height that each number needs // Default: 31
widthNumber: Width of the numbers' image // Default: 14
offsetRight: Distance to the right // Default: 0
spaceNumbers: Separation between the numbers' columns // Default: 0
widthDot: Decimal dot's special width // Default: 10
formatNumber: Whether to format the number with commas every 3 digits // Default: false
We can override the defaults with:
$.fn.jOdometer.defaults.spaceNumbers = 1;
It returns an object used for counter manipulation. Available Functions:
goToNumber(number): Updates the counter with the number given. Example:
var counter = $('.counter').jOdometer({...});
counter.goToNumber(100);
</pre>
<h1>jOdometer samples:</h1>
<pre>
</pre>
<div class="counter1"></div>
<div class="counter2"></div>
<div class="counter3"></div>
<div class="counter4"></div>
Example manual update:
<div class="counter5"></div>
<div class="counter6"></div>
Counter 1: <input type="text" id="input-1" /> <input type="button" id="input-1-button" value="Update" />
<br />
Counter 2: <input type="text" id="input-2" /> <input type="button" id="input-2-button" value="Update" />
<br />
<input type="button" id="update-both-button" value="Update Both" />
</body>
</html>