From 5be222f2d36818b8de21b857ce7be7fb88a735af Mon Sep 17 00:00:00 2001 From: Alexsander Vyshnyvetskyy Date: Mon, 19 Dec 2016 16:20:59 +0400 Subject: [PATCH] Waypoints and `triggerOnce` fix `triggerOnce` was removed in Waypoints. Add `try` support for Waypoints and `triggerOnce` fix. --- jquery.counterup.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/jquery.counterup.js b/jquery.counterup.js index bc7871f..7cebc86 100644 --- a/jquery.counterup.js +++ b/jquery.counterup.js @@ -75,9 +75,18 @@ }; // Perform counts when the element gets into view - $this.waypoint(counterUpper, { offset: '100%', triggerOnce: true }); + try { + $this.waypoint(function (direction) { + counterUpper(); + this.destroy(); + }, { + offset: '100%' + }); + } catch (e) { + counterUpper(); + }; }); }; -})( jQuery ); \ No newline at end of file +})( jQuery );