From d3ae77cf8b14e7be320d30e4c8dfe8cf39c9b49a Mon Sep 17 00:00:00 2001 From: carlosmintfan <118076740+carlosmintfan@users.noreply.github.com> Date: Sat, 1 Feb 2025 17:01:29 -0300 Subject: [PATCH] Enable scrollSpy in countup module (#2113) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Paweł Kuna <1282324+codecalm@users.noreply.github.com> --- .changeset/famous-items-tap.md | 5 +++++ src/js/src/countup.js | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/famous-items-tap.md diff --git a/.changeset/famous-items-tap.md b/.changeset/famous-items-tap.md new file mode 100644 index 000000000..3854c566b --- /dev/null +++ b/.changeset/famous-items-tap.md @@ -0,0 +1,5 @@ +--- +"@tabler/core": patch +--- + +Enable `scrollSpy` in `countup` module diff --git a/src/js/src/countup.js b/src/js/src/countup.js index edc132bda..7ff7fb5fb 100644 --- a/src/js/src/countup.js +++ b/src/js/src/countup.js @@ -4,7 +4,9 @@ if (elements.length) { elements.forEach(function (element) { let options = {}; try { - options = element.getAttribute('data-countup') ? JSON.parse(element.getAttribute('data-countup')) : {}; + const dataOptions = element.getAttribute('data-countup') ? JSON.parse(element.getAttribute('data-countup')) : {}; + options = Object.assign({'enableScrollSpy': true}, dataOptions); + } catch (error) {} const value = parseInt(element.innerHTML, 10); @@ -14,4 +16,4 @@ if (elements.length) { countUp.start(); } }); -} \ No newline at end of file +}