Aurelia and XCode/iOs Simulator Problem - Fix

#1

Hi,
when using Aurelia and Testing the App in the iOs Simulator from XCode and you have a Mac that uses the Intel 3000/4000 Hd
(or if you are in a VM, what never ever can happen, because you applied to the copyright notice from osx :wink: )
the refresh of the display does not really work when the content changes without a navigation (think of something that has XXX.bind like selecting items in a list that are then displayed in a form).

The not so nice solution is to tap twice in the view, but you will never know if that was the refresh problem or if something in your app went wrong.

So i found out that refreshing the DOM, after Aurelia did itโ€™s screen Update (per default each 200ms, so i use 250ms) forces the Simulator Safari to redraw. Here is my Code (which constantly calles itself):

invalidateScreen = function() {
        if (!environment.debug || window.navigator.userAgent.indexOf('iPad') < 0 || window.location.port != '9000' ) return;

        document.body.style.opacity = "0.999";

        window.setTimeout(() => {
            document.body.style.opacity = "1";
            window.setTimeout(() => invalidateScreen(), 250);
        }, 250);
    }

Please feel free to correct or amend my approach. Itโ€™s working, but maybe there is another/better/cleaner way to force the update.

Best regards

2 Likes