MCPcopy Create free account
hub / github.com/chartjs/Chart.js / parseMaxStyle

Function parseMaxStyle

src/helpers/helpers.dom.ts:29–43  ·  view source on GitHub ↗

* convert max-width/max-height values that may be percentages into a number * @private

(styleValue: string | number, node: HTMLElement, parentProperty: string)

Source from the content-addressed store, hash-verified

27 */
28
29function parseMaxStyle(styleValue: string | number, node: HTMLElement, parentProperty: string) {
30 let valueInPixels: number;
31 if (typeof styleValue === 'string') {
32 valueInPixels = parseInt(styleValue, 10);
33
34 if (styleValue.indexOf('%') !== -1) {
35 // percentage * size in dimension
36 valueInPixels = (valueInPixels / 100) * node.parentNode[parentProperty];
37 }
38 } else {
39 valueInPixels = styleValue;
40 }
41
42 return valueInPixels;
43}
44
45const getComputedStyle = (element: HTMLElement): CSSStyleDeclaration =>
46 element.ownerDocument.defaultView.getComputedStyle(element, null);

Callers 2

getContainerSizeFunction · 0.85
getMaximumSizeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected