Merge pull request #1148 from jaredwindover/dev_Preview_Patch
Retypeset if changes while typesetting
This commit is contained in:
commit
7395bbbb3d
|
@ -23,6 +23,7 @@ var Preview = {
|
||||||
|
|
||||||
timeout: null, // store setTimout id
|
timeout: null, // store setTimout id
|
||||||
mjRunning: false, // true when MathJax is processing
|
mjRunning: false, // true when MathJax is processing
|
||||||
|
mjPending: false, // true when a typeset has been queued
|
||||||
oldText: null, // used to check if an update is needed
|
oldText: null, // used to check if an update is needed
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -67,15 +68,20 @@ var Preview = {
|
||||||
//
|
//
|
||||||
CreatePreview: function () {
|
CreatePreview: function () {
|
||||||
Preview.timeout = null;
|
Preview.timeout = null;
|
||||||
if (this.mjRunning) return;
|
if (this.mjPending) return;
|
||||||
var text = document.getElementById("MathInput").value;
|
var text = document.getElementById("MathInput").value;
|
||||||
if (text === this.oldtext) return;
|
if (text === this.oldtext) return;
|
||||||
|
if (this.mjRunning) {
|
||||||
|
this.mjPending = true;
|
||||||
|
MathJax.Hub.Queue(["CreatePreview",this]);
|
||||||
|
} else {
|
||||||
this.buffer.innerHTML = this.oldtext = text;
|
this.buffer.innerHTML = this.oldtext = text;
|
||||||
this.mjRunning = true;
|
this.mjRunning = true;
|
||||||
MathJax.Hub.Queue(
|
MathJax.Hub.Queue(
|
||||||
["Typeset",MathJax.Hub,this.buffer],
|
["Typeset",MathJax.Hub,this.buffer],
|
||||||
["PreviewDone",this]
|
["PreviewDone",this]
|
||||||
);
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -83,7 +89,7 @@ var Preview = {
|
||||||
// and swap the buffers to show the results.
|
// and swap the buffers to show the results.
|
||||||
//
|
//
|
||||||
PreviewDone: function () {
|
PreviewDone: function () {
|
||||||
this.mjRunning = false;
|
this.mjRunning = this.mjPending = false;
|
||||||
this.SwapBuffers();
|
this.SwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user