'useGrouping' setting ignored on dynamically created countup
See original GitHub issue[X] Bug
[ ] Feature request
CountUp.js version: 2.2.0
Description
Case: multiple instances created within an observer (‘enableScrollSpy’ was not compatible with another script). Grouping is by default active and that’s fine, except for 1 number, it needs to be disabled. The dynamic settings come from data-attributes and work fine so far. But only the ‘useGrouping’ setting is ignored. Tested: disabling grouping by default - works.
let countups = {};
let timeouts = {};
const counters = document.querySelectorAll(".number-item");
const countersObserver = new IntersectionObserver (function (entries, observer) {
var i = 0;
entries.forEach(function(entry) {
if (entry.isIntersecting) {
var cid = entry.target.id
cno = entry.target.dataset.number,
suf = entry.target.dataset.suffix || "",
time = entry.target.dataset.time || "2",
sep = entry.target.dataset.sep || ".",
grp = entry.target.dataset.group || true,
opts = {
'enableScrollSpy': false,
'suffix': suf,
'duration': time,
'separator': sep,
'useGrouping': grp
}
countups[entry.target.id]= new countUp.CountUp(cid, cno, opts );
timeouts[entry.target.id] = setTimeout(() => {
countups[entry.target.id].start();
}, 0 + (500*i) );
observer.unobserve(entry.target);
}
i++;
},{});
});
counters.forEach ( function (countUpItems) {
countersObserver.observe(countUpItems);
});
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
SOQL and SOSL Reference - Salesforce Implementation guides
Dynamic SOQL in Apex—Apex requires that you surround SOQL and SOSL ... Aggregate functions on page 53 in SOQL queries ignore null values, ......
Read more >Spread for ASP.NET Developer's Guide - GrapeCity
This guide provides introductory conceptual material and how-to explanations for routine tasks for developers using. Spread for ASP.NET.
Read more >by Bernd Klein - Python Courses eu
I created a basic syntax, used indentation for statement grouping instead of curly braces or begin-end blocks, and developed a small number of...
Read more >Learning Targets - Findley Elementary
1-Phoemic Awareness : Identify initial, medial, and final sounds in a single syllable word. Count number of sounds in a syllable and count...
Read more >Overview - Joe Sandbox
Created File. DNS/IP Info; Is Dropped; Is Windows Process; Number of created Registry Values; Number of created Files; Visual Basic; Delphi ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A the last info was helpful. The check failed on the empy separator. Fixed it with:
sep = (entry.target.dataset.sep==="") ? "" : ".",
Removed the grouping data attribute and now it works as intended. Thanks!Btw: countUp is awesome with data-attributes and many instances.
Ok so I see this:
The value of the attribute is string
"false"
and I don’t know if that’s coerced into a boolean or not. But even if it was you are doinggrp = false || true
which will set it to true.Last, you are supposedly setting an empty separator, and CountUp will set useGrouping to false given an empty separator. So I don’t understand how you are interpreting that it is ignoring useGrouping when you’ve passed an empty separator?