(fitties)
| 39 | |
| 40 | // redraws fitties so they nicely fit their parent container |
| 41 | const redraw = (fitties) => { |
| 42 | // getting info from the DOM at this point should not trigger a reflow, let's gather as much intel as possible before triggering a reflow |
| 43 | |
| 44 | // check if styles of all fitties have been computed |
| 45 | fitties |
| 46 | .filter((f) => !f.styleComputed) |
| 47 | .forEach((f) => { |
| 48 | f.styleComputed = computeStyle(f); |
| 49 | }); |
| 50 | |
| 51 | // restyle elements that require pre-styling, this triggers a reflow, please try to prevent by adding CSS rules (see docs) |
| 52 | fitties.filter(shouldPreStyle).forEach(applyStyle); |
| 53 | |
| 54 | // we now determine which fitties should be redrawn |
| 55 | const fittiesToRedraw = fitties.filter(shouldRedraw); |
| 56 | |
| 57 | // we calculate final styles for these fitties |
| 58 | fittiesToRedraw.forEach(calculateStyles); |
| 59 | |
| 60 | // now we apply the calculated styles from our previous loop |
| 61 | fittiesToRedraw.forEach((f) => { |
| 62 | applyStyle(f); |
| 63 | markAsClean(f); |
| 64 | }); |
| 65 | |
| 66 | // now we dispatch events for all restyled fitties |
| 67 | fittiesToRedraw.forEach(dispatchFitEvent); |
| 68 | }; |
| 69 | |
| 70 | const markAsClean = (f) => (f.dirty = DrawState.IDLE); |
| 71 |
no test coverage detected
searching dependent graphs…