delay setting q/a if previous operation is still running

fixes incorrect formatting when undoing previous review then immediately
hitting enter
This commit is contained in:
Damien Elmes 2017-10-24 17:09:22 +10:00
parent 944bca0f44
commit d02901fb7a

View file

@ -1,5 +1,6 @@
var ankiPlatform = "desktop";
var typeans;
var _updatingQA = false;
var qFade = 100;
var aFade = 0;
@ -14,6 +15,15 @@ function _runHook(arr) {
}
function _updateQA(html, fadeTime, onupdate, onshown) {
// if a request to update q/a comes in before the previous content
// has been loaded, wait a while and try again
if (_updatingQA) {
setTimeout(function () { _updateQA(html, fadeTime, onupdate, onshown) }, 50);
return;
}
_updatingQA = true;
onUpdateHook = [onupdate];
onShownHook = [onshown];
@ -38,6 +48,7 @@ function _updateQA(html, fadeTime, onupdate, onshown) {
MathJax.Hub.Queue(function () {
qa.fadeTo(fadeTime, 1, function () {
_runHook(onShownHook);
_updatingQA = false;
});
});
});