diff --git a/README.md b/README.md index 6a17d40..b09ad5d 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Usage **Include** ``` - + ``` diff --git a/counterup.jquery.json b/counterup.jquery.json index 89bf645..7ed3bb6 100644 --- a/counterup.jquery.json +++ b/counterup.jquery.json @@ -1,6 +1,6 @@ { "name": "counterup", - "version": "1.0.0", + "version": "1.0.1", "title": "Counter-Up", "description": "A lightweight jQuery plugin that counts up to a targeted number when the number becomes visible.", "keywords": [ @@ -33,4 +33,4 @@ "waypoints": ">=2.0" }, "demo": "http://bfintal.github.io/Counter-Up/demo/demo.html" -} \ No newline at end of file +} diff --git a/demo/demo.html b/demo/demo.html index dc32556..03c444b 100644 --- a/demo/demo.html +++ b/demo/demo.html @@ -118,7 +118,7 @@

(Scroll down)

<body>
    <span class="counter">1,234,567</span>
-     <script src="//cdnjs.cloudflare.com/ajax/libs/waypoints/2.0.3/waypoints.min.js"></script>
+     <script src="//cdnjs.cloudflare.com/ajax/libs/waypoints/4.0.1/jquery.waypoints.min.js"></script>
    <script src="jquery.counterup.min.js"></script>
</body> @@ -154,7 +154,7 @@

(Scroll down)

958393.10 5,123,348 - + \ No newline at end of file diff --git a/jquery.counterup.js b/jquery.counterup.js index bc7871f..60a97a0 100644 --- a/jquery.counterup.js +++ b/jquery.counterup.js @@ -72,12 +72,15 @@ // Start the count up setTimeout($this.data('counterup-func'), $settings.delay); + + // Destroy waypoint so that it will be triggered only once + this.destroy(); }; // Perform counts when the element gets into view - $this.waypoint(counterUpper, { offset: '100%', triggerOnce: true }); + $this.waypoint(counterUpper, { offset: '100%' }); }); }; -})( jQuery ); \ No newline at end of file +})( jQuery ); diff --git a/jquery.counterup.min.js b/jquery.counterup.min.js index cddf5a1..943d994 100644 --- a/jquery.counterup.min.js +++ b/jquery.counterup.min.js @@ -5,4 +5,4 @@ * Released under the GPL v2 License * * Date: Nov 26, 2013 -*/(function(e){"use strict";e.fn.counterUp=function(t){var n=e.extend({time:400,delay:10},t);return this.each(function(){var t=e(this),r=n,i=function(){var e=[],n=r.time/r.delay,i=t.text(),s=/[0-9]+,[0-9]+/.test(i);i=i.replace(/,/g,"");var o=/^[0-9]+$/.test(i),u=/^[0-9]+\.[0-9]+$/.test(i),a=u?(i.split(".")[1]||[]).length:0;for(var f=n;f>=1;f--){var l=parseInt(i/n*f);u&&(l=parseFloat(i/n*f).toFixed(a));if(s)while(/(\d+)(\d{3})/.test(l.toString()))l=l.toString().replace(/(\d+)(\d{3})/,"$1,$2");e.unshift(l)}t.data("counterup-nums",e);t.text("0");var c=function(){t.text(t.data("counterup-nums").shift());if(t.data("counterup-nums").length)setTimeout(t.data("counterup-func"),r.delay);else{delete t.data("counterup-nums");t.data("counterup-nums",null);t.data("counterup-func",null)}};t.data("counterup-func",c);setTimeout(t.data("counterup-func"),r.delay)};t.waypoint(i,{offset:"100%",triggerOnce:!0})})}})(jQuery); \ No newline at end of file +*/(function(e){"use strict";e.fn.counterUp=function(t){var n=e.extend({time:400,delay:10},t);return this.each(function(){var t=e(this),r=n,i=function(){var e=[],n=r.time/r.delay,i=t.text(),s=/[0-9]+,[0-9]+/.test(i);i=i.replace(/,/g,"");var o=/^[0-9]+$/.test(i),u=/^[0-9]+\.[0-9]+$/.test(i),a=u?(i.split(".")[1]||[]).length:0;for(var f=n;f>=1;f--){var l=parseInt(i/n*f);u&&(l=parseFloat(i/n*f).toFixed(a));if(s)while(/(\d+)(\d{3})/.test(l.toString()))l=l.toString().replace(/(\d+)(\d{3})/,"$1,$2");e.unshift(l)}t.data("counterup-nums",e);t.text("0");var c=function(){t.text(t.data("counterup-nums").shift());if(t.data("counterup-nums").length)setTimeout(t.data("counterup-func"),r.delay);else{delete t.data("counterup-nums");t.data("counterup-nums",null);t.data("counterup-func",null)}};t.data("counterup-func",c);setTimeout(t.data("counterup-func"),r.delay);this.destroy()};t.waypoint(i,{offset:"100%"})})}})(jQuery);