PencilCode/jquery-turtle — pull request #21 by davidbau (2014-01-19 01:47:35+00:00)
Title: Clean up the implementation of wear(url).

When you change the image for a turtle, it changes size, which messes up the location of the center of the turtle.

The old code used to have a bunch of hacks to try to listen to the "onload" event and fix the location of the turtle to keep it center on the same spot at that moment, but it was buggy because various browsers would change the size of the image and move it long before the event (or they sometimes fired the event too early or failed to fire the event entirely).

The new code deals with the unreliability of "onload" by just loading the image offscreen. Then once it's loaded and we can see the dimensions, the turtle is flipped atomically to the new size and src url.