Skip to content
This repository has been archived by the owner on Aug 22, 2021. It is now read-only.

Add callback function when the counter up finishes #31

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions demo/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
jQuery(document).ready(function( $ ) {
$('.counter').counterUp({
delay: 10,
time: 1000
time: 1000,
callback: function(e) { console.log(e); }
});
});
</script>
Expand Down Expand Up @@ -157,4 +158,4 @@ <h3>(Scroll down)</h3>
<script src="http://cdnjs.cloudflare.com/ajax/libs/waypoints/2.0.3/waypoints.min.js"></script>
<script src="../jquery.counterup.min.js"></script>
</body>
</html>
</html>
6 changes: 4 additions & 2 deletions jquery.counterup.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
// Defaults
var settings = $.extend({
'time': 400,
'delay': 10
'delay': 10,
'callback': function() {}
}, options);

return this.each(function(){
Expand Down Expand Up @@ -66,6 +67,7 @@
delete $this.data('counterup-nums');
$this.data('counterup-nums', null);
$this.data('counterup-func', null);
$settings.callback($this);
}
};
$this.data('counterup-func', f);
Expand All @@ -80,4 +82,4 @@

};

})( jQuery );
})( jQuery );
2 changes: 1 addition & 1 deletion jquery.counterup.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.