Last Updated: February 25, 2016
·
1.414K
· iam4x

Ask webkit iOS a repaint

On iOS6 I had a problem with elements not rendered after changing page in my JS SinglePageApp.

To resolve that, I needed to ask webkit to repaint the view. Two solutions :

forceRedraw: (el) ->
    element = $(el)
    newEl = document.createTextNode(' ')
    element.append(newEl)
    newEl.parentNode.removeChild newEl
    element

And the magic one \o/ :

el.style.webkitTransform = el.style.webkitTransform

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside