Implement an option to disable automatic scrolling
This adds a checkbox with which one can disable scrolling, for example to look back at output during testing. Note that the styles are inline because the test runner removes all <style> elements for each test.
This commit is contained in:
parent
07ec736eb9
commit
e02ab9fb79
@ -96,9 +96,11 @@ var SimpleTextLayerBuilder = (function SimpleTextLayerBuilderClosure() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} DriverOptions
|
* @typedef {Object} DriverOptions
|
||||||
* @property {HTMLPreElement} output - Container for all output messages.
|
|
||||||
* @property {HTMLSpanElement} inflight - Field displaying the number of
|
* @property {HTMLSpanElement} inflight - Field displaying the number of
|
||||||
* inflight requests.
|
* inflight requests.
|
||||||
|
* @property {HTMLInputElement} disableScrolling - Checkbox to disable
|
||||||
|
* automatic scrolling of the output container.
|
||||||
|
* @property {HTMLPreElement} output - Container for all output messages.
|
||||||
* @property {HTMLDivElement} end - Container for a completion message.
|
* @property {HTMLDivElement} end - Container for a completion message.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -118,8 +120,9 @@ var Driver = (function DriverClosure() {
|
|||||||
PDFJS.enableStats = true;
|
PDFJS.enableStats = true;
|
||||||
|
|
||||||
// Set the passed options
|
// Set the passed options
|
||||||
this.output = options.output;
|
|
||||||
this.inflight = options.inflight;
|
this.inflight = options.inflight;
|
||||||
|
this.disableScrolling = options.disableScrolling;
|
||||||
|
this.output = options.output;
|
||||||
this.end = options.end;
|
this.end = options.end;
|
||||||
|
|
||||||
// Set parameters from the query string
|
// Set parameters from the query string
|
||||||
@ -410,9 +413,9 @@ var Driver = (function DriverClosure() {
|
|||||||
this.output.textContent += message;
|
this.output.textContent += message;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.lastIndexOf('\n') >= 0) {
|
if (message.lastIndexOf('\n') >= 0 && !this.disableScrolling.checked) {
|
||||||
// Scroll to the bottom of the page
|
// Scroll to the bottom of the page
|
||||||
window.scrollTo(0, document.body.scrollHeight);
|
this.output.scrollTop = this.output.scrollHeight;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -29,14 +29,19 @@ limitations under the License.
|
|||||||
<script src="driver.js"></script>
|
<script src="driver.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<pre id="output"></pre>
|
|
||||||
<p>Inflight requests: <span id="inflight"></span></p>
|
<p>Inflight requests: <span id="inflight"></span></p>
|
||||||
|
<p>
|
||||||
|
<input type="checkbox" id="disableScrolling">
|
||||||
|
<label for="disableScrolling">Disable automatic scrolling</label>
|
||||||
|
</p>
|
||||||
|
<pre id="output" style="max-height: 800px; overflow-y: scroll;"></pre>
|
||||||
<div id="end"></div>
|
<div id="end"></div>
|
||||||
</body>
|
</body>
|
||||||
<script>
|
<script>
|
||||||
var driver = new Driver({
|
var driver = new Driver({
|
||||||
output: document.getElementById('output'),
|
disableScrolling: document.getElementById('disableScrolling'),
|
||||||
inflight: document.getElementById('inflight'),
|
inflight: document.getElementById('inflight'),
|
||||||
|
output: document.getElementById('output'),
|
||||||
end: document.getElementById('end')
|
end: document.getElementById('end')
|
||||||
});
|
});
|
||||||
driver.run();
|
driver.run();
|
||||||
|
Loading…
Reference in New Issue
Block a user