react-gauge-component
Advanced tools
Comparing version 1.2.51 to 1.2.61
@@ -121,2 +121,3 @@ "use strict"; | ||
var _a; | ||
setTimeout(function () { return window.dispatchEvent(new Event('resize')); }, 10); | ||
if (!((_a = selectedRef.current) === null || _a === void 0 ? void 0 : _a.offsetParent)) | ||
@@ -136,2 +137,31 @@ return; | ||
}, [props]); | ||
// useEffect(() => { | ||
// console.log(selectedRef.current?.offsetWidth) | ||
// // workaround to trigger recomputing of gauge size on first load (e.g. F5) | ||
// setTimeout(() => window.dispatchEvent(new Event('resize')), 10); | ||
// }, [selectedRef.current?.parentNode]); | ||
(0, react_1.useEffect)(function () { | ||
var element = selectedRef.current; | ||
if (!element) | ||
return; | ||
var handleResize = function () { | ||
var parentNode = element.parentNode; | ||
if (parentNode) { | ||
chartHooks.renderChart(gauge, true); | ||
// console.log("Parent node width:", width); | ||
} | ||
}; | ||
// Create a ResizeObserver to watch the parent node | ||
var observer = new ResizeObserver(handleResize); | ||
// Observe the parent node | ||
if (element.parentNode) { | ||
observer.observe(element.parentNode); | ||
} | ||
// Cleanup observer when component unmounts | ||
return function () { | ||
if (element.parentNode) { | ||
observer.unobserve(element.parentNode); | ||
} | ||
}; | ||
}, []); | ||
var id = props.id, style = props.style, className = props.className, type = props.type; | ||
@@ -138,0 +168,0 @@ return (react_1.default.createElement("div", { id: id, className: "".concat(gauge.props.type, "-gauge").concat(className ? ' ' + className : ''), style: style, ref: function (svg) { return (selectedRef.current = svg); } })); |
{ | ||
"name": "react-gauge-component", | ||
"version": "1.2.51", | ||
"version": "1.2.61", | ||
"main": "dist/lib/index.js", | ||
@@ -84,2 +84,3 @@ "module": "dist/lib/index.js", | ||
"react-dom": "^17.0.1", | ||
"react-grid-layout": "^1.4.4", | ||
"react-scripts": "^5.0.1", | ||
@@ -86,0 +87,0 @@ "rimraf": "^2.7.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
118346
2060
36