Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.

Commit 245a1bc

Browse files
committed
Merge PR bfintal#27
2 parents 094db62 + ff9dd6a commit 245a1bc

File tree

5 files changed

+29
-12
lines changed

5 files changed

+29
-12
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Features:
1111

1212
* Auto-detect for integers, floats or formatted numbers
1313
* The plugin will also use the number of decimal places the original number is using.
14+
* Start counter with a different duration and delay by setting `data-counterup-time=""` and `data-counterup-delay=""`
1415
* Lightweight: ~1kb
1516
* Minimal setup
1617

@@ -44,11 +45,16 @@ CDN provided by [jsDelivr CDN](http://www.jsdelivr.com/#!jquery.counterup)
4445

4546
**HTML**
4647

48+
With default values from plugin instantiation.
4749
```
4850
<span class="counter">1,234,567.00</span>
4951
<span>$</span><span class="counter">1.99</span>
5052
<span class="counter">12345</span>
5153
```
54+
With values from `data` attribute.
55+
```
56+
<span class="counter" data-counterup-time="1500" data-counterup-delay="30">1,234,567.00</span>
57+
```
5258

5359
**jQuery**
5460

counterup.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "counterup",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"title": "Counter-Up",
55
"description": "A lightweight jQuery plugin that counts up to a targeted number when the number becomes visible.",
66
"keywords": [

demo/demo.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
21
<!doctype html>
3-
42
<html lang="en">
53
<head>
64
<meta charset="utf-8">
7-
85
<title>Counter Up Demo</title>
96
<meta name="description" content="Counter Up - jQuery Plugin Demo">
107
<meta name="author" content="Benjamin Intal">
@@ -33,7 +30,7 @@
3330
span {
3431
font-size: 33px;
3532
color: #555;
36-
margin-bottom: 350px;
33+
margin-bottom: 250px;
3734
display: inline-block;
3835
font-weight: 400;
3936
text-align: center;
@@ -129,6 +126,11 @@ <h3>(Scroll down)</h3>
129126
<span class="counter" style="display: inline-block; width: 32%">1.9583</span>
130127
<span class="counter" style="display: inline-block; width: 32%">12345</span>
131128
</div>
129+
<div>
130+
<span class="counter" data-counterup-time="1000" data-counterup-delay="25" style="display: inline-block; width: 32%">52,147</span>
131+
<span class="counter" data-counterup-time="1500" style="display: inline-block; width: 32%">1.9583</span>
132+
<span class="counter" data-counterup-time="2000" style="display: inline-block; width: 32%">12345</span>
133+
</div>
132134
<div>
133135
<span style="display: inline-block; width: 32%"><span>$</span><span class="counter">43,753</span></span>
134136
<span class="counter" style="display: inline-block; width: 32%">1,734,195.10</span>

jquery.counterup.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*!
2-
* jquery.counterup.js 1.0
2+
* jquery.counterup.js 1.1.0
33
*
44
* Copyright 2013, Benjamin Intal http://gambit.ph @bfintal
55
* Released under the GPL v2 License
66
*
7-
* Date: Nov 26, 2013
7+
* Date: Feb 05, 2016
88
*/
99
(function( $ ){
1010
"use strict";
@@ -22,11 +22,15 @@
2222

2323
// Store the object
2424
var $this = $(this);
25-
var $settings = settings;
25+
26+
var counter = {
27+
time: $(this).data('counterup-time') || settings.time,
28+
delay: $(this).data('counterup-delay') || settings.delay
29+
};
2630

2731
var counterUpper = function() {
2832
var nums = [];
29-
var divisions = $settings.time / $settings.delay;
33+
var divisions = counter.time / counter.delay;
3034
var num = $this.text();
3135
var isComma = /[0-9]+,[0-9]+/.test(num);
3236
num = num.replace(/,/g, '');
@@ -84,7 +88,7 @@
8488
var f = function() {
8589
$this.text($this.data('counterup-nums').shift());
8690
if ($this.data('counterup-nums').length) {
87-
setTimeout($this.data('counterup-func'), $settings.delay);
91+
setTimeout($this.data('counterup-func'), counter.delay);
8892
} else {
8993
delete $this.data('counterup-nums');
9094
$this.data('counterup-nums', null);
@@ -95,7 +99,7 @@
9599
$this.data('counterup-func', f);
96100

97101
// Start the count up
98-
setTimeout($this.data('counterup-func'), $settings.delay);
102+
setTimeout($this.data('counterup-func'), counter.delay);
99103
};
100104

101105
// Perform counts when the element gets into view

jquery.counterup.min.js

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)