(elm: HTMLElement | string | null)
| 493 | }; |
| 494 | |
| 495 | const getSize = (elm: HTMLElement | string | null): { w: number; h: number } => { |
| 496 | const $elm = get(elm); |
| 497 | |
| 498 | if (!$elm) { |
| 499 | return { w: 0, h: 0 }; |
| 500 | } |
| 501 | |
| 502 | let w = getStyle($elm, 'width'); |
| 503 | let h = getStyle($elm, 'height'); |
| 504 | |
| 505 | // Non pixel value, then force offset/clientWidth |
| 506 | if (!w || w.indexOf('px') === -1) { |
| 507 | w = '0'; |
| 508 | } |
| 509 | |
| 510 | // Non pixel value, then force offset/clientWidth |
| 511 | if (!h || h.indexOf('px') === -1) { |
| 512 | h = '0'; |
| 513 | } |
| 514 | |
| 515 | return { |
| 516 | w: parseInt(w, 10) || $elm.offsetWidth || $elm.clientWidth, |
| 517 | h: parseInt(h, 10) || $elm.offsetHeight || $elm.clientHeight |
| 518 | }; |
| 519 | }; |
| 520 | |
| 521 | const getRect = (elm: string | HTMLElement): GeomRect => { |
| 522 | const $elm = get(elm); |
no test coverage detected
searching dependent graphs…