websanova/wScratchPad — pull request #36 by patricknelson (2014-07-15 17:29:55+00:00)
Title: Fixed race condition that affected Android + Chrome on mobile when a "sc...

I ended up with a race condition that affected Android + Chrome on mobile when a "scratchDown" callback was also setup. What happened was that the callback was being called with `this._scratchPercent()` being executed, which took some time in portrait mode but interestingly not landscape. Anyway, this caused Chrome 35 to automatically trigger a `touchcancel` event since it took longer than 200ms to respond, which foobar'ed everything, causing `touchmove` events never to be fired and thus created bullet holes instead of lines when attempting to scratch (just dropped a circle and did nothing else).

Fixed involves deferring callbacks via `setTimeout()` so that `touchstart` will return immediately. I also modified the logic on firing callbacks slightly to just exclude `scratchMove` if not currently set to `realtime` in the options.