I have a hybrid iOS app which contains a WKWebView
, and I have a JavaScript function callNative
can call Objective C native code in the main thread.
In my JavaScript, I have the following structure
modifyDOM(); // e.g. .show(), and .hide() stuff
callNative('animateWKWebViewFrame');
For some reason, animateWKWebViewFrame
(native code) is called before modifyDOM
completes and is fully rendered. (This causes a visual glitch.)
How can I force full rendering of DOM modifications before calling native code?
I am assuming that you are using jQuery because of your comment saying modifyDOM
calls show()
and hide()
. If that is the case, then you should rely on the complete
parameter to provide a function that will, in turn, make the call to your native code.
The relevant documentation is here :
http://api.jquery.com/hide/#hide-duration-complete
http://api.jquery.com/show/#show-duration-complete
And finally, here is some sample code :
function modifyDOM()
{
someElement.show(400, function() {callNative('animateWKWebViewFrame');});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With