mirror of
https://github.com/tabler/tabler.git
synced 2026-10-12 05:06:55 +04:00
Fix CountUp, dropdown viewport boundary, and input mask lazy option (#2684)
This commit is contained in:
1 parent
218b0c5f15
commit
b1d49e9762
6 files changed
+24
-5
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@tabler/core": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fixed CountUp to parse formatted number targets and avoid double-start when `enableScrollSpy` is enabled.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@tabler/core": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fixed dropdown `data-bs-boundary="viewport"` to use `document.documentElement` instead of the first `.btn` element.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@tabler/core": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fixed input mask `lazy` option to read `data-mask-visible` via `dataset.maskVisible`.
|
||||||
@@ -15,11 +15,15 @@ if (countupElements.length) {
|
|||||||
// ignore invalid JSON
|
// ignore invalid JSON
|
||||||
}
|
}
|
||||||
|
|
||||||
const value = parseInt(element.innerHTML, 10)
|
// Strip thousands separators, currency symbols and other non-numeric characters
|
||||||
|
// so formatted targets like "1,234", "1 234" or "$99.5" parse correctly.
|
||||||
|
const value = parseFloat((element.textContent ?? '').replace(/[^0-9.-]/g, ''))
|
||||||
|
|
||||||
if (window.countUp && window.countUp.CountUp) {
|
if (!Number.isNaN(value) && window.countUp && window.countUp.CountUp) {
|
||||||
const countUp = new window.countUp.CountUp(element, value, options)
|
const countUp = new window.countUp.CountUp(element, value, options)
|
||||||
if (!countUp.error) {
|
// When scrollSpy is enabled CountUp starts the animation itself once the
|
||||||
|
// element scrolls into view, so only start manually when it's disabled.
|
||||||
|
if (!countUp.error && !options.enableScrollSpy) {
|
||||||
countUp.start()
|
countUp.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ Core dropdowns
|
|||||||
const dropdownTriggerList: HTMLElement[] = [].slice.call(document.querySelectorAll<HTMLElement>('[data-bs-toggle="dropdown"]'))
|
const dropdownTriggerList: HTMLElement[] = [].slice.call(document.querySelectorAll<HTMLElement>('[data-bs-toggle="dropdown"]'))
|
||||||
dropdownTriggerList.map(function (dropdownTriggerEl: HTMLElement) {
|
dropdownTriggerList.map(function (dropdownTriggerEl: HTMLElement) {
|
||||||
const options = {
|
const options = {
|
||||||
boundary: dropdownTriggerEl.getAttribute('data-bs-boundary') === 'viewport' ? document.querySelector('.btn') : 'clippingParents',
|
boundary: dropdownTriggerEl.getAttribute('data-bs-boundary') === 'viewport' ? document.documentElement : 'clippingParents',
|
||||||
}
|
}
|
||||||
return new Dropdown(dropdownTriggerEl, options)
|
return new Dropdown(dropdownTriggerEl, options)
|
||||||
})
|
})
|
||||||
@@ -5,6 +5,6 @@ maskElementList.map(function (maskEl: HTMLElement) {
|
|||||||
window.IMask &&
|
window.IMask &&
|
||||||
new window.IMask(maskEl, {
|
new window.IMask(maskEl, {
|
||||||
mask: maskEl.dataset.mask,
|
mask: maskEl.dataset.mask,
|
||||||
lazy: maskEl.dataset['mask-visible'] === 'true',
|
lazy: maskEl.dataset.maskVisible !== 'true',
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
Reference in new issue
Block a user