Wait for next animation frame before measuring when stylesheets change

Fixes #4479